Home > Database > Mysql Tutorial > body text

How Docker creates and runs multiple mysql containers

WBOY
Release: 2023-06-01 13:52:14
forward
1759 people have browsed it

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
Copy after login

How Docker creates and runs multiple mysql containers

  • ilink_user_01 is the container Name, specify

  • 123456 as the password of the database root through the --name command, specify the environment mysql_root_password as 123456 through -e, -e (specify the environment variable in the container)

  • -d Using the -d parameter, the container will enter the background. The user cannot see the information in the container and cannot perform operations.

  • 3307:3306 is Port mapping, specify the local host port 3307 to be mapped to the container's 3306 port

2. Enter the instance to modify the mysql configuration information

docker exec -it ilink_user_01 bash
Copy after login

How Docker creates and runs multiple mysql containers

  • exec can directly execute human commands inside the container

  • Use the parameter -it to open the interactive terminal of the container, and users can easily communicate with Containers interact without affecting the normal operation of other applications in the container

3. View all users in the mysql database

select distinct concat('user: ''',user,'''@''',host,''';') as query from mysql.user;
Copy after login

How Docker creates and runs multiple mysql containers

4. Modify the root user of mysql to allow users to log in from any IP

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

flush privileges;
Copy after login

How Docker creates and runs multiple mysql containers

5. Use navicat to test Connection

How Docker creates and runs multiple mysql containers

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';
Copy after login

How Docker creates and runs multiple mysql containers

7. Reuse navicat to connect

How Docker creates and runs multiple mysql containers

The above is the detailed content of How Docker creates and runs multiple mysql containers. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:yisu.com
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!