简单方法
Show me the fucking code
mysql -u root -p
grant all privileges on *.* to root@"your ip address" identified by "password" with grant option;
flush privileges;
如果想省事,允许所有ip,直接用'%'
grant all privileges on *.* to root@"%" identified by "password" with grant option;
分析
SELECT host,user,password FROM user WHERE user = 'root';
image.png
结果发现host是'%'的用户密码不对,所以总是连接失败,需要改变密码
UPDATE `user` SET Password=PASSWORD("new password") WHERE Host='%' AND User='root';
flush privileges;
重启mysql
sudo service mysqld restart
网友评论