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 Docker creates and runs multiple mysql containers

2025-01-22 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

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

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.

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

Development

Wechat

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

12
Report