一、报错
使用ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY '123';
修改MySQL8.0数据库密码的时候报错:
1251 client does not support authentication protocol requested by
server;consider upgrading Mysql client ERROR 1396 (HY000): Operation
ALTER USER failed for ‘root’@‘localhost’
二、解决
1、登录mysql
mysql -u root -p
输入密码
2、切换数据库
mysql> use mysql;
3、查询用户
mysql> select user,host from user;
+------------------+-----------+| user | host |+------------------+-----------+| root | % || admin | localhost || mysql.infoschema | localhost || mysql.session | localhost || mysql.sys | localhost || zhangj | localhost |+------------------+-----------+
可知,root用户的host并不是localhost,即不是root@localhost,而是root@%。
4、重试修改密码
ALTER USER 'root'@'%' IDENTIFIED WITH mysql_native_password BY '123';
修改成功。
参考:http://t.csdn.cn/fARcP
来源地址:https://blog.csdn.net/qq_33187368/article/details/129921184