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

How to implement real-time polygon refraction with threejs

Table of contents Preface Step 1: Setup and front...

HTML+CSS to achieve charging water drop fusion special effects code

Table of contents Preface: accomplish: Summarize:...

Steps to install MySQL using Docker under Linux

As a tester, you may often need to install some s...

How to set background blur with CSS

When making some pages, in order to make the page...

Solution to the paging error problem of MySQL one-to-many association query

The query data in the xml price inquiry contains ...

Solution to MySQL garbled code problem under Linux

The project interacts with the server, accesses t...

The first step in getting started with MySQL database is to create a table

Create a database Right click - Create a new data...

Installation and configuration method of Zabbix Agent on Linux platform

Here is a brief summary of the installation and c...

How to recover deleted MySQL 8.0.17 root account and password under Windows

I finished learning SQL by myself not long ago, a...

How to add default time to a field in MySQL

Date type differences and uses MySQL has five dat...

Detailed explanation of MySQL Strict Mode knowledge points

I. Strict Mode Explanation According to the restr...

Node.js solves the problem of Chinese garbled characters in client request data

Node.js solves the problem of Chinese garbled cha...

Introduction to Computed Properties in Vue

Table of contents 1. What is a calculated propert...

MySQL 5.7 generated column usage example analysis

This article uses examples to illustrate the usag...