1.无法通过公网、局域网IP登陆
切换数据库:
use mysql;
授权host为任意地址
update user set host = ‘%’ where user = ‘root’;
刷新 flush privileges;或重启数据库
2.在本地密码错误无法登陆
在mysql8.0以上版本:
update mysql.user set password='newpassword' where user='root';
update mysql.user set password=PASSWORD('newpassword') where User='root';
以上两条命令已经不起作用了,需要使用以下命令设置新密码:
alter user 'root'@'localhost' identified by 'newpassword'; newpassword
设置新密码后,用以下命令刷新数据库
flush privileges;