ERROR 1698 (28000): Access denied for user 'root'@'localhost' 解决方法

之前MySQL服务端本机上使用密码登陆root账号是没有问题的,但是今天不知道是因为动了哪里,登陆失败并有这个错误代码:

~$ mysql -u root -p
Enter password:
ERROR 1698 (28000): Access denied for user ‘root‘@‘localhost‘

解决步骤:

停止mysql服务

~$ sudo service mysql stop

以安全模式启动MySQL

~$ sudo mysqld_safe --skip-grant-tables &

MySQL启动之后就可以不用密码登陆了

~$ mysql -u root
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 2
Server version: 5.7.10 MySQL Community Server (GPL)

查看一下user表,错误的起因就是在这里, root的plugin被修改成了auth_socket,用密码登陆的plugin应该是mysql_native_password。

mysql> select user, plugin from mysql.user;
+-----------+-----------------------+
| user      | plugin                |
+-----------+-----------------------+
| root      | auth_socket           |
| mysql.sys | mysql_native_password |
| dev       | mysql_native_password |
+-----------+-----------------------+
3 rows in set (0.01 sec)

关于auth_socket,在官方有说明: https://dev.mysql.com/doc/mysql-security-excerpt/5.5/en/socket-authentication-plugin.html ,反正现在暂时不用它, 那就把这里改了。

mysql> update mysql.user set authentication_string=PASSWORD(‘newPwd‘), plugin=‘mysql_native_password‘ where user=‘root‘;
Query OK, 1 row affected, 1 warning (0.00 sec)
Rows matched: 1  Changed: 1  Warnings: 1

mysql> flush privileges;
Query OK, 0 rows affected (0.00 sec)

重启服务,问题就解决了

~$ sudo service mysql stop
...
 * MySQL Community Server 5.7.10 is stopped
~$ sudo service mysql start
..
 * MySQL Community Server 5.7.10 is started
~$ mysql -u root -p
Enter password:
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 2
Server version: 5.7.10 MySQL Community Server (GPL)

ERROR 1698 (28000): Access denied for user 'root'@'localhost' 解决方法

原文地址:https://www.cnblogs.com/bootdo/p/10390486.html

时间: 2024-11-05 18:30:35

ERROR 1698 (28000): Access denied for user 'root'@'localhost' 解决方法的相关文章

MySQL ERROR 1698 (28000): Access denied for user 'root'@'localhost'

今天在安装MySQL的过程中竟然没有让我输入密码,登录的时候也不需要密码就能进入,这让我很困惑. 进了数据库就设置密码,用了各种方式都不行. 虽然我这数据库没啥东西但也不能没有密码就裸奔啊,有点丢人是吧. Google了一下,找到了解决的办法. 看到了root的plugin是auth_socket mysql> USE mysql;mysql> UPDATE user SET plugin='mysql_native_password' WHERE User='root';mysql>

ERROR 1698 (28000): Access denied for user 'root'@'localhost'

在新版的 Ubuntu (如 16.04,18.04)中,安装好 MySQL 后直接用下面的命令连接总是会报错: $ mysql ERROR 1045 (28000): Access denied for user 'feiffy'@'localhost' (using password: NO) $ mysql -u root ERROR 1698 (28000): Access denied for user 'root'@'localhost' 这是因为 mysql 默认的 root 用户

Ubuntu下连接mysql出现 ERROR 1698 (28000): Access denied for user 'root'@'localhost'错误解决方法

ubuntu版本:18.04    mysql版本:5.7.24 ubuntu安装mysql后用root账户登入会出现问题:ERROR 1698 (28000): Access denied for user 'root'@'localhost' 可能是因为初始密码为空:按空格回车后还是报一样的错 这样就只能使用debian-sys-maint账户修改root账户密码了. debian-sys-maint账户是安装mysql时系统自动生成的mysql用户,debian和ubuntu系统都会这样做

MySQL使用普通用户访问返回ERROR 1698 (28000): Access denied for user 'root'@'localhost'

这个问题最开始查资料都说要改密码,密码不对.其实不是这个样子都. 解决方法 修改/etc/mysql/my.cnf,添加以下内容 [mysqld] skip-grant-tables 重启mysql服务/etc/init.d/mysql restart 使用mysql -u root连接 执行select user, plugin from mysql.user; 若显示以下结果,请继续:若没有,这篇文章解决不了. +------------------+--------------------

ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: NO)

在安装好的MySQL服务器上,配置了环境变量之后,发现用mysql无法登录,报如题的错误,实在没有办法,决定用安全模式对root用户修改密码: 首先在一个ssh窗口运行命令:mysqld_safe --user=mysql --skip-grant-tables --skip-networking& [[email protected] ~]# mysqld_safe --user=mysql --skip-grant-tables --skip-networking& 运行之后新打开一个

Mac下解决mysql ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: YES)

Maybe updating the package the updater overwrote the root password. To restore it: Stop mysqld deamons. $ sudo service mysqld stop Go to mysql/bin directory $ cd /usr/bin Start a mysql deamon with this option: $ sudo mysqld_safe --skip-grant-tables O

升级到macOS 10.12 mysqlb报错ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: NO)

系统升级到macOS 10.12后启动mysql后,在终端输入mysql 报错ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: YES/NO) 解决办法1 在系统偏好设置里关闭mySQL2 $ cd /usr/bin3 $ sudo mysqld_safe --skip-grant-tables4 再打开一个终端$ mysqlmysql> use mysql;mysql> UPDATE

MySQL使用错误解决:ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: NO)

解决方法: ⑴打开mysql中的my.ini(如果没有就将my-default.ini复制一份,并修改为my.ini): ⑵在[mysqld]下面空白行直接添加skip-grant-tables: ⑶重启mysql,在cmd页面输入mysql,按回车键即可. 注:这会使你的mysql无法设置密码,但对个人使用而言这岂不是更省了一步! MySQL使用错误解决:ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using p

ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: YES)

To start mysqld at boot time you have to copysupport-files/mysql.server to the right place for your system PLEASE REMEMBER TO SET A PASSWORD FOR THE MySQL root USER !To do so, start the server, then issue the following commands: /usr/bin/mysqladmin -