MySQL ERROR 1698 (28000) 错误

看很多网上的做法都是先停止mysql服务

$ sudo mysql service stop

然后以安全模式启动数据库

$ sudo mysqld_safe --skip-grant-tables &
$ mysql -u root

然后查看root的插件

mysql> select user,host,plugin from mysql.user;
+------------------+-----------+-----------------------+
| user             | host      | plugin                |
+------------------+-----------+-----------------------+
| root             | localhost | auth_socket           |
| mysql.session    | localhost | mysql_native_password |
| mysql.sys        | localhost | mysql_native_password |
| debian-sys-maint | localhost | mysql_native_password |
| root             | %         |                       |
| myuser           | localhost | mysql_native_password |
+------------------+-----------+-----------------------+
6 rows in set (0.00 sec)

就会发现root的插件是auth_socket,很多人都改成了mysql_native_password,这里,我觉得禁止插件是最好的选择,省去了很多麻烦,也不需要重置密码。
所以博主的做法是首先

$ sudo mysql -u root

根本不需要停止mysql并且以安全模式登录。
然后换成mysql数据库

mysql> use mysql;
mysql> update user set plugin='' where User='root';
mysql> flush privileges;
mysql> exit;

再次查看

mysql> select user,host,plugin from mysql.user;
+------------------+-----------+-----------------------+
| user             | host      | plugin                |
+------------------+-----------+-----------------------+
| root             | localhost |                       |
| mysql.session    | localhost | mysql_native_password |
| mysql.sys        | localhost | mysql_native_password |
| debian-sys-maint | localhost | mysql_native_password |
| root             | %         |                       |
| myuser           | localhost | mysql_native_password |
+------------------+-----------+-----------------------+
6 rows in set (0.00 sec)

这样就ok啦~

文章来源: MySQL ERROR 1698 (28000) 错误

人吐槽 人点赞

猜你喜欢

发表评论

用户名: 密码:
验证码: 匿名发表

你可以使用这些语言

查看评论:MySQL ERROR 1698 (28000) 错误