Get the App
SLTechnology News&Howtos  ›  Development  › 

How Docker creates and runs multiple mysql containers

Shulou Source: shulou.com Published: 2022-06-01 03:36:29 09月22日 Update

This article mainly introduces "Docker how to create and run multiple mysql containers" related knowledge, editor through the actual case to show you the operation process, the method of operation is simple and fast, practical, I hope that this "Docker how to create and run multiple mysql containers" article can help you solve the problem.

1. Quickly start a mysql instance using a mysql/mysql-server:latest image

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

Ilink_user_01 is the name of the container, specified by the-- name directive

123456 is the password of the database root, and specify the environment mysql_root_password as 123456 (specify the environment variable in the container) through-e.

-d uses the-d parameter, and the container enters the background, and the user cannot see the information in the container and cannot operate.

3307 3306 is the port mapping, specifying that local host port 3307 is mapped to port 3306 of the container

two。 Enter the instance to modify mysql configuration information

Docker exec-it ilink_user_01 bash

Exec can execute staff commands directly inside the container

Parameter-it is used to save the input in the table. Before the submarine does not affect 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 user

Update mysql.user set host='%' where user='root';flush privileges

5. Use navicat to test the connection

Authentication plugin 'caching_sha2_password', appears because the mysql image is encrypted using caching_sha2_password, while navicat does not support caching_sha2_password encryption

6. Resolve authentication plugin 'caching_sha2_password'

Alter user 'root'@'%' identified with mysql_native_password by' 123456'

7. Re-use navicat connection

That's all for "how Docker creates and runs multiple mysql containers". Thank you for reading. If you want to know more about the industry, you can follow the industry information channel. The editor will update different knowledge points for you every day.

Tags: Container user multiple run knowledge port information parameter instance data database environment industry encryption difference utility host person content variable Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Shulou Technology Xiaomi Linux vpn Huawei