Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to run multiple mysql containers in Docker

2025-01-16 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)06/01 Report--

How do I run multiple mysql containers in Docker? Many novices are not very clear about this. In order to help you solve this problem, the following editor will explain it in detail. People with this need can come and learn. I hope you can gain something.

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

Is it helpful for you to read the above content? If you want to know more about the relevant knowledge or read more related articles, please follow the industry information channel, thank you for your support.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report