突然mysql 无法连接ERROR 1045 (28000)Access denied......

xiaoxiao2021-02-28  34

突然localhost无法连接,远程也无法连接!!!! 在Linux中登录#mysql -u root -p 进入数据库是总是错误 ERROR 1045 (28000): Access denied for user ''@'localhost' (using password: YES)

1、查看root用户授权:host字段的值改为%就表示在任何客户端机器上能以root用户登录到mysql服务器

我开始来排查

2、修改MySQL配置文件,使得可以无密码登录mysql # vim /etc/my.cnf 在[mysqld]项下添加 skip-grant-tables

3、重启mysql服务 # service mysql restart 4、无密码登录 #mysql -u root -p #use mysql; 5、授权 SQL>flush privileges; SQL>grant all privileges on *.* to 'root'@'localhost' identified by '123456';   SQL>flush privileges;  注意: 6、再次查看user表 7、还原配置文件 my.cnf,重启下服务,再次连接 本地成功连接 远程成功连接

转载请注明原文地址: https://www.6miu.com/read-2620164.html

最新回复(0)