ubuntu18.04 mysql5.7 突然出现Access denied for user 'root'@'localhost' (using password: YES)

[root] vi /etc/mysql/mysql.conf.d/mysqld.cnf

注释掉 #bind-address           = 127.0.0.1

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

表示root用户密码错误了

修改/etc/mysql/mysql.conf.d/mysqld.cnf

[mysqld]
skip-grant-tables

[root]sudo /etc/init.d/mysql restart

[root]mysql

mysql>use mysql;

mysql>update user set authentication_string = password("root") where user= 'root';

mysql> flush privileges;

mysql> quit;

修改  sudo vi /etc/mysql/mysql.conf.d/mysqld.cnf

[mysqld]
#skip-grant-tables

[root]sudo /etc/init.d/mysql restart
 

猜你喜欢

转载自blog.csdn.net/wjg1314521/article/details/103628836