从新搭建开发环境,修改MySQL密码后登录时出现标题所述错误。 Server version: 5.7.29 MySQL Community Server (GPL) 后发现使用初始密码登录成功,故怀疑修改密码时存在问题。
未成功修改密码的代码为: set password for root@localhost=password('xxxxxx');
尝试使用另外一种方式:
UPDATE mysql.user SET authentication\_string=PASSWORD('yourPassword') where User='root';
出现错误:
ERROR 1820 (HY000): You must reset your password using ALTER USER statement before executing this statement.
根据错误提示设置密码:
ALTER USER 'root'@'localhost' IDENTIFIED BY 'yourPassword';
成功,刷新权限表并退出:
FLUSH PRIVILEGES; exit;