欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页  >  IT编程

MySql Error 1698(28000)问题的解决方法

程序员文章站 2022-05-19 08:57:46
一,问题描述: mysqlerror1698(28000)解决,新装了mysql-server-5.7,登录为这一问题,普通用户不能进mysql,只有root用户才能进,...

一,问题描述:

mysqlerror1698(28000)解决,新装了mysql-server-5.7,登录为这一问题,普通用户不能进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 |
+-----------+-----------------------+
<strong>3</strong> rows in set (<strong>0.01</strong> sec)

关于auth_socket,在官方有说明: ,反正现在暂时不用它, 那就把这里改了。

mysql> update mysql.user set authentication_string=password('newpwd'), plugin='mysql_native_password' where user='root';
query ok, <strong>1</strong> row affected, <strong>1</strong> warning (<strong>0.00</strong> sec)
rows matched: <strong>1</strong> changed: <strong>1</strong> warnings: <strong>1</strong>
mysql> flush privileges;
query ok, <strong>0</strong> rows affected (<strong>0.00</strong> 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)

以上所述是小编给大家介绍的mysql error 1698(28000)问题的解决方法,希望对大家有所帮助