Docker Installing MySQL and Implementing Remote Connection Tutorial

  • 2021-08-31 09:40:10
  • OfStack

Pull mirror image


docker pull mysql

View the image that has been pulled


docker images

Create and start 1 MySQL container through mirroring


docker run --name mysql_dev -e MYSQL_ROOT_PASSWORD=123456 -p 3333:3306 -d mysql

name: Name the newly created container, here named mysql_dev
-e: Configuration information, where the login password of root user for mysql is configured
-p: Port mapping, where host port 3333 is mapped to port 3306 of container mysql_dev
-d: Outputs the full ID of the container after successful start\ The last mysql refers to the mysql mirror name

At this point, connect mysql with navicat for mysql and report an error:
Client does not support authentication protocol requested by server. . .
Solve the bottom ^ _ ^

View all installed containers


docker ps -a

View containers in startup


docker ps

Pause/start the service in the container


docker stop mysql_dev
docker start mysql_dev

Enter the container


docker exec -it mysql_dev bash

View the IP of the service in the container


docker exec -it mysql_dev cat /etc/hosts

near 'IDENTIFIED BY' Password 'with grant option' at line 1

1 Question:

When using grant permission list on database to 'username' @ 'access host' identified by 'password'; The error "...... near 'identified by' Password '' at line 1" occurs when

2 Reason:

Because the new version of mysql has separated the way accounts are created from the way permissions are granted

3 Solution:

Create an account: create user 'User Name' @ 'Access Host' identified by 'Password';
Give permissions: grant permissions list on database to 'username' @ 'access host'; (Add with grant option to modify permissions)

4 Specific operation:


#  Add User 
CREATE USER 'mysql_dev' IDENTIFIED BY '123456';
#  Give permission 
GRANT ALL PRIVILEGES ON *.* TO 'mysql_dev'@'%';
#  Modify encryption rules  
ALTER USER 'mysql_dev'@'%' IDENTIFIED BY '123456' PASSWORD EXPIRE NEVER;
#  Update 1 The password of the user under 
ALTER USER 'mysql_dev'@'%' IDENTIFIED WITH mysql_native_password BY '123456';
#  Update configuration information 
FLUSH PRIVILEGES;

The above is the Docker installation MySQL and remote connection tutorial details, more about Docker installation MySQL and remote connection information please pay attention to other related articles on this site!


Related articles: