docker ps |grep mysql
docker exec -it a00ba5071c1e /bin/bash
Add skip-grant-tables
code in the last line ( //Skip the password verification of mysql)
(if there is no password in the container For the vim command, you can use the commands apt-get update
, apt-get install vim
to download and install vim)
vim /etc/mysql/conf.d/docker.cnf
service mysql restart
docker restart a00ba5071c1e
docker exec -it a00ba5071c1e /bin/bash
to log in to the database without entering a password, just press Enter
mysql -u root -p
use mysql
update user set authentication_string=password('123') where user="root";
Delete the just added skip-grant-tables
vim /etc/mysql/conf.d/docker.cnf
service mysql restart
docker restart a00ba5071c1e
The above is the detailed content of How to change the user password of MySQL in the docker container. For more information, please follow other related articles on the PHP Chinese website!