手打不易,转载注明出处:https://zhangxiaofan.blog.csdn.net/article/details/84555847
mysql连数据库的时候报错:
1251 client does not support authentication protocol requested by server;consider upgrading Mysql client
ERROR 1396 (HY000): Operation ALTER USER failed for 'root'@'localhost'
先登录mysql
mysql -u root -p
输入密码
mysql> use mysql;
mysql> select user,host from user;
+------------------+-----------+
| user | host |
+------------------+-----------+
| root | % |
| admin | localhost |
| mysql.infoschema | localhost |
| mysql.session | localhost |
| mysql.sys | localhost |
| zhangj | localhost |
+------------------+-----------+
注意我的 root,host是'%'
你可能执行的是:
ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY '123';
改成:
ALTER USER 'root'@'%' IDENTIFIED WITH mysql_native_password BY '123';
如果还是不行:
尝试一:重置密码为空
先登录MySQL,重置密码为空,并刷新
update user set authentication_string='' where user='root';
flush privileges;
再用上面的方法修改密码