我在宿主机上连接mysql时,执行语句mysql -uroot -proot123 -h192.168.217.128 -P3306
出现如下错误ERROR 1045 (28000): Access denied for user 'root'@'192.168.217.1' (using password: YES)
但是我的密码正确,Linux 的防火墙也关了,selinux也关了,就是不能登录进去。
原因: mysql的用户不仅仅是一个类似root,或者user的,它的账号是和主机地址相关联的,出现这个问题的原因就是我的root账户没有在本机授权。
解决方法:
grant all privileges on *.* to root@'%' identified by 'root123';
flush privileges;