Step 1: MySQL container
Docker exec - it container ID / bin / Bash
Step 2 connect to MySQL
mysql -uroot -p
After entering the password, log in to the MySQL terminal
Step 3: change the password
Set password for 'root' = password ('set password ');
Step 4 restart
Restart the MySQL container
Docker restart container ID
Supplement: docker starts MySQL container and initializes default password – e MySQL_ ROOT_ PASSWORD
docker run -p 3308:3308 --name=mysql -e MYSQL_ROOT_PASSWORD=123456 mysql:5.6
Initializing database
[[email protected] mugutu]# docker run -p 3308:3308 --name=mysql -e MYSQL_ROOT_PASSWORD=123456 mysql:5.6
Initializing database
2018-12-02 13:42:53 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details).
2018-12-02 13:42:53 0 [Note] Ignoring --secure-file-priv value as server is running with --bootstrap.
2018-12-02 13:42:53 0 [Note] /usr/sbin/mysqld (mysqld 5.6.41) starting as process 32 ...
The above is my personal experience. I hope I can give you a reference, and I hope you can support developpaer. If there are mistakes or not fully considered, please don’t hesitate to comment.