How does docker modify the root password of mysql

  • 2021-10-25 00:11:37
  • OfStack

Step 1 mysql container


docker exec -it  Container ID /bin/bash

Step 2 Connect mysql


mysql -uroot -p

After entering the password, log in to the mysql terminal

Step 3 Change the password


SET PASSWORD FOR 'root' = PASSWORD(' Password set ');

Step 4 Restart

Restart the mysql container


docker restart  Container ID

Added: docker Startup mysql Container Startup Initialization Default Password Problem-e MYSQL_ROOT_PASSWORD


docker run -p 3308:3308 --name=mysql -e MYSQL_ROOT_PASSWORD=123456 mysql:5.6
Initializing database

[root@localhost 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 ...

Related articles: