MySQL报错:ERROR 1396 (HY000): Operation ALTER USER failed for root@localhost

我们登录进入MySQL,并执行修改密码命令:

alter user 'root'@'localhost' identified by 'root';

MySQL报错:ERROR 1396 (HY000): Operation ALTER USER failed for root@localhost
这时会报错,错误信息为:

ERROR 1396 (HY000): Operation ALTER USER failed for ‘root’@‘localhost’

执行命令:

use mysql

select user,host from user;

结果显示为:
MySQL报错:ERROR 1396 (HY000): Operation ALTER USER failed for root@localhost
这里我们可以看到,我的user为root,而我的host为%,所以我的命令应该改为:

alter user 'root'@'%' identified by 'root';

执行命令:
MySQL报错:ERROR 1396 (HY000): Operation ALTER USER failed for root@localhost
成功更改密码并解决报错问题。

上一篇:2059-authentication plugin 'caching_sha2_password"cnnot bt loaded :mysql8.0数据库连接不上(Navicat


下一篇:ERROR 2003 (HY000): Can't connect to MySQL server on 'localhost' (10061)