1. 版本信息
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 11
Server version: 8.0.31 MySQL Community Server - GPL
Copyright (c) 2000, 2022, Oracle and/or its affiliates.
Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.
2. 执行步骤,修改my.cnf 再重启Docker 镜像
最新版本Docker hub 其实可以直接修改文件
在my.cnf 的部分增加 skip-grant-tables
3. 打开 Terminal 执行步骤
切记: 先执行 flush 再重新设置,否则执行update password 报错:
mysql> flush privileges;
Query OK, 0 rows affected (0.00 sec)
mysql> SET PASSWORD FOR 'root'@'localhost' = '你的密码';
Query OK, 0 rows affected (0.01 sec)
如果未执行 flush 的报错信息如下所示:
ERROR 1290 (HY000): The MySQL server is running with the --skip-grant-tables option so it cannot execute this statement
ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '('你的密码') WHERE USER='root' and Host='localhost'' at line 1
再修改,然后 再把my.cnf 改回来,重启docker 镜像就可以了。
网友评论