1.进入容器
docker exec -it xxxx bash
2.使用root账号登录mysql
mysql -u root -p
3.查看当前加密方式
- use mysql;
- SELECT Host, User, plugin from user;
我这是改过了,应该都是caching_sha2_password
4. 修改加密方式,同时也可修改密码(本地和远程登录)
- ALTER USER 'root'@'%' IDENTIFIED WITH mysql_native_password BY 'root';
- ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY 'root';
插入修改密码的另一种方式(本地和远程登录)
- ALTER USER 'root'@'localhost' IDENTIFIED BY 'Pwd@123456';
- ALTER USER 'root'@'%' IDENTIFIED BY 'Pwd@123456';
5.刷新权限
flush privileges;
6.查看是否修改成功
SELECT Host, User, plugin from user;