Access denied for user 'root'@'192.168.56.56' (using password: YES) 问题排查

Access denied for user 'root'@'192.168.56.56' (using password: YES) 问题排查

报错如下:
mysql -h192.168.56.56 -P3306 -uroot -p123456
mysql: [Warning] Using a password on the command line interface can be insecure.
ERROR 1045 (28000): Access denied for user 'root'@'192.168.56.56' (using password: YES)


上述报错的可能原因: 
1.连接信息填写错误(IP、PORT、USER、PASSWORD) 
检查对应信息是否填写错误。


2.网络不通。 

可能网络没有调通或者存在防火墙,检查IP和端口是否连通 
ping 192.168.56.56
telnet 192.168.56.56 3306


3.密码过期或者用户被锁定。 

检查用户定义
mysql>  show create user 'root'@'%';
 

4.用户定义了host,客户端IP不在允许范围内。 

检查用户定义
mysql>  show create user 'root'@'%';


5.MySQL配置了错误的bind_address,比如只允许本地登录。

[root@localhost data]# grep 'bind_address' /etc/my.cnf 
bind_address='127.0.0.1'

[root@localhost data]# netstat -tpln |grep mysqld
tcp        0      0 127.0.0.1:3306          0.0.0.0:*               LISTEN      18533/mysqld

示例中MySQL配置了绑定到127.0.0.1回环接口,无法通过其他IP访问。配置文件中去掉这个配置并重启MySQL即可。

Access denied for user 'root'@'192.168.56.56' (using password: YES) 问题排查
报错如下:mysql -h192.168.56.56 -P3306 -uroot -p123456mysql: [Warning] Using a password on the command line interface can be insecure.ERROR 1045 (28000): Access denied for user 'root'@'192.168.56.56' (using password: YES)

上述报错的可能原因: 1.连接信息填写错误(IP、PORT、USER、PASSWORD) 检查对应信息是否填写错误。

2.网络不通。 
可能网络没有调通或者存在防火墙,检查IP和端口是否连通 ping 192.168.56.56telnet 192.168.56.56 3306

3.密码过期或者用户被锁定。 
检查用户定义mysql>  show create user 'root'@'%'; 
4.用户定义了host,客户端IP不在允许范围内。 
检查用户定义mysql>  show create user 'root'@'%';

5.MySQL配置了错误的bind_address,比如只允许本地登录。
[root@localhost data]# grep 'bind_address' /etc/my.cnf bind_address='127.0.0.1'
[root@localhost data]# netstat -tpln |grep mysqldtcp        0      0 127.0.0.1:3306          0.0.0.0:*               LISTEN      18533/mysqld
示例中MySQL配置了绑定到127.0.0.1回环接口,无法通过其他IP访问。配置文件中去掉这个配置并重启MySQL即可。



原文地址:https://www.cnblogs.com/l10n/p/13502134.html