Home > Database > Mysql Tutorial > How to change the user password of MySQL in the docker container

How to change the user password of MySQL in the docker container

WBOY
Release: 2023-05-29 21:34:04
forward
4826 people have browsed it

1. View the started MySQL container id

docker ps |grep mysql
Copy after login

How to change the user password of MySQL in the docker container

2. Enter the started MySQL container

docker exec -it a00ba5071c1e /bin/bash
Copy after login
Copy after login

How to change the user password of MySQL in the docker container

3. Modify the MySQL configuration file

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
Copy after login
Copy after login

How to change the user password of MySQL in the docker container

4. Restart the database

service mysql restart
Copy after login

How to change the user password of MySQL in the docker container

5. Restart the MySQL container

docker restart a00ba5071c1e
Copy after login
Copy after login

How to change the user password of MySQL in the docker container

6. Enter the started MySQL container again

docker exec -it a00ba5071c1e /bin/bash
Copy after login
Copy after login

How to change the user password of MySQL in the docker container

6. Use the statement mysql -u root -p statement

to log in to the database without entering a password, just press Enter

mysql -u root -p
Copy after login

How to change the user password of MySQL in the docker container

7.Use MySQL database

use mysql
Copy after login

How to change the user password of MySQL in the docker container

8.Update user password

update user set authentication_string=password('123') where user="root";
Copy after login

How to change the user password of MySQL in the docker container

9. Exit mysql

How to change the user password of MySQL in the docker container

10. Edit the mysql configuration file again

Delete the just added skip-grant-tables

vim /etc/mysql/conf.d/docker.cnf
Copy after login
Copy after login

How to change the user password of MySQL in the docker container

11. Restart mysql again

service mysql restart
Copy after login

How to change the user password of MySQL in the docker container

12. Restart the docker container again

docker restart a00ba5071c1e
Copy after login
Copy after login

How to change the user password of MySQL in the docker container

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!

Related labels:
source:yisu.com
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template