【Vegas原创】mysql8忘记密码的终极解决方案(dockercompose)

MYSQL8的安全性能有所提高,装好后,各种不适应,需要各种调试。

1. 首先,root密码忘记或是更改,操作步骤:

vi mysql/config/my.cnf

在[mysqld]的段中加上一句:skip-grant-tables 保存并且退出vi。
docker-compose restart
进入bash,运行mysql -uroot -p ,回车,直接进入。
下面很重要,特别是flush privileges,千万别忘。
update user set authentication_string='' where user='root';

alter user 'root'@'localhost' identified by '新密码';

alter user 'root'@'%' identified by '新密码';

FLUSH PRIVILEGES;

然后,各种测试。只到测试成功。


然后,谨记,再回到my.cnf ,删除skip-grant-tables
喜欢请赞赏一下啦^_^
原文地址:https://www.cnblogs.com/amadeuslee/p/15696996.html