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

10 tips for designing useful, easy-to-use web applications

Here are 10 tips on how to design better-usable w...

How to solve the problem of margin overlap

1. First, you need to know what will trigger the v...

Summary of the top ten problems of MySQL index failure

Table of contents background 1. The query conditi...

Let's talk about parameters in MySQL

Preface: In some previous articles, we often see ...

js native carousel plug-in production

This article shares the specific code for the js ...

Detailed explanation of MySQL's FreeList mechanism

1. Introduction After MySQL is started, BufferPoo...

Zen HTML Elements Friends who use zen coding can collect it

html ¶ <html></html> html:xml ¶ <h...

Vue two fields joint verification to achieve the password modification function

Table of contents 1. Introduction 2. Solution Imp...

Do you know how to use the flash wmode attribute in web pages?

When doing web development, you may encounter the...

Zookeeper unauthorized access test problem

Table of contents Preface Detect Zookeeper servic...

Detailed explanation of Mysql communication protocol

1.Mysql connection method To understand the MySQL...

Linux firewall status check method example

How to check the status of Linux firewall 1. Basi...

Solution to MySQL Chinese garbled characters problem

1. The Chinese garbled characters appear in MySQL...

JavaScript implementation of carousel example

This article shares the specific code for JavaScr...