Example of how to create and run multiple MySQL containers in Docker

Example of how to create and run multiple MySQL containers in Docker

1. Use the mysql/mysql-server:latest image to quickly start a MySQL instance

docker run --name ilink_user_01 -e MYSQL_ROOT_PASSWORD=123456 0d 0p 3307:3306 mysql/mysql-server:latest 

  • ilink_user_01 is the container name, specified by the --name command
  • 123456 is the password of the database root. -e specifies the environment MYSQL_ROOT_PASSWORD to 123456. -e (specifies the environment variables in the container)
  • -d With the -d parameter, the container will enter the background, and the user cannot see the information in the container or perform operations
  • 3307:3306 is the port mapping, which specifies that the local host port 3307 is mapped to the container's port 3306

2. Enter the instance to modify the mysql configuration information

docker exec -it ilink_user_01 bash 

  • exec can execute human commands directly inside the container
  • The -it parameter is used to save the table input to open, without affecting other applications in the container, the user can easily interact with the container

3. View all users in the MYSQL database

SELECT DISTINCT CONCAT('User: ''',user,'''@''',host,''';') AS query FROM mysql.user; 

4. Modify the root user of mysql to allow login from any ip

update mysql.user set host='%' where user='root';

flush privileges; 

5. Test the connection using navicat

The authentication plugin 'caching_sha2_password' appears because the MySQL image is encrypted using caching_sha2_password, and Navicat does not support the caching_sha2_password encryption method.

6. Solve the authentication plugin 'caching_sha2_password'

ALTER USER 'root'@'%' IDENTIFIED WITH mysql_native_password BY '123456'; 

7. Re-use navicat connection

The above is the full content of this article. I hope it will be helpful for everyone’s study. I also hope that everyone will support 123WORDPRESS.COM.

You may also be interested in:
  • How to initialize the Mysql database when the Docker container starts
  • Detailed explanation of importing/exporting MySQL data in Docker container
  • Detailed explanation of building a Mysql container + Tomcat container connection environment through Docker
  • How to create a MySQL container with Docker
  • Detailed explanation of creating a MySQL container with Docker and connecting to the container through the command line
  • Using Docker containers to build MySql master-slave replication
  • How to use Mysql in Tomcat container under Docker
  • Introduction to Docker connection spring boot and mysql container method
  • Simple steps to create a MySQL container with Docker
  • Modification of time zone problem of MySQL container in Docker

<<:  How to query json in the database in mysql5.6 and below

>>:  Solve the problem of garbled Chinese characters in Mysql5.7

Recommend

Share 16 burning flame effect English fonts treasure trove

We live in a visual world and are surrounded by m...

How to use SessionStorage and LocalStorage in Javascript

Table of contents Preface Introduction to Session...

MySQL index optimization: paging exploration detailed introduction

Table of contents MySQL Index Optimization Paging...

Detailed explanation of using INS and DEL to mark document changes

ins and del were introduced in HTML 4.0 to help au...

Summary of Vue watch monitoring methods

Table of contents 1. The role of watch in vue is ...

50 lines of code to implement Webpack component usage statistics

background Recently, a leader wanted us to build ...

How to achieve 3D dynamic text effect with three.js

Preface Hello everyone, this is the CSS wizard - ...

MySQL Flush-List and dirty page flushing mechanism

1. Review The Buffer Pool will be initialized aft...

Vue.js implements simple timer function

This article example shares the specific code of ...

Vue uses rules to implement form field validation

There are many ways to write and validate form fi...

Pure CSS to change the color of the picture

The css technique for changing the color of an im...

How to deploy the crownblog project to Alibaba Cloud using docker

Front-end project packaging Find .env.production ...

Summary of how to use bootstrap Table

This article shares with you how to use bootstrap...

Vue/react single page application back without refresh solution

Table of contents introduction Why bother? Commun...

Solve the problem of blank gap at the bottom of Img picture

When working on a recent project, I found that th...