mysql 修改root密码失败 ,主要是因为root的host不是localhost,是%的问题。
-- 切换到 mysql bin 路径
--先登录mysql
mysql -u root -p
--输入密码
-- 切换到mysql数据
use 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'@'%' IDENTIFIED WITH mysql_native_password BY '123';