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

Steps to transplant the new kernel to the Linux system

1. Download the ubuntu16.04 image and the corresp...

Analysis of the difference between emits and attrs in Vue3

Table of contents in conclusion Practice Analysis...

Differences between this keyword in NodeJS and browsers

Preface Anyone who has learned JavaScript must be...

The use of mysql unique key in query and related issues

1. Create table statement: CREATE TABLE `employee...

Detailed explanation of the reasons why MySQL connections are hung

Table of contents 1. Background Architecture Prob...

Vue keeps the user logged in (various token storage methods)

Table of contents How to set cookies Disadvantage...

Example code for drawing double arrows in CSS common styles

1. Multiple calls to single arrow Once a single a...

Docker case analysis: Building a MySQL database service

Table of contents 1 Create configuration and data...

CSS3 sample code to achieve element arc motion

How to use CSS to control the arc movement of ele...