How to modify the root password of mysql in docker

How to modify the root password of mysql in docker

The first step is to create a 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 password

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

Step 4: Restart

Restart the mysql container

docker restart container id

Supplement: Docker starts the MySQL container to start the 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) started as process 32 ...

The above is my personal experience. I hope it can give you a reference. I also hope that you will support 123WORDPRESS.COM. If there are any mistakes or incomplete considerations, please feel free to correct me.

You may also be interested in:
  • How to obtain a permanent free SSL certificate from Let''s Encrypt in Docker
  • Docker solution for logging in without root privileges
  • How to change the root password in a container using Docker
  • How to obtain root permissions in a docker container
  • docker cp copy files and enter the container
  • Docker uses root to enter the container
  • Solution to the Docker container not having permission to write to the host directory
  • How to add a certificate to docker

<<:  Scoring rules of YSlow, a webpage scoring plugin developed by Yahoo

>>:  Use of filter() array filter in JS

Recommend

How to implement paging query in MySQL

SQL paging query:background In the company's ...

Detailed explanation of common Docker Compose commands

1. The use of Docker compose is very similar to t...

Pure js to achieve the effect of carousel

This article shares the specific code of js to ac...

React example showing file upload progress

Table of contents React upload file display progr...

Detailed explanation of CSS label mode display property

The code looks like this: <!DOCTYPE html> &...

HTML table_Powernode Java Academy

To draw a table in HTML, use the table tag tr me...

How many common loops do you know about array traversal in JS?

Preface As a basic data structure, arrays and obj...

JavaScript implements long image scrolling effect

This article shares the specific code of JavaScri...

CSS delivery address parallelogram line style example code

The code looks like this: // Line style of the pa...