Technical work, should be praised and then see, form a habitCopy the code

Docker use tutorial related series of directories


Pull mysql image

Docker pull mysql: 5.7Copy the code

Docker common operation mirror command

Run the mysql image

Docker run -d --name mysql57 -p 3306:3306 -e MYSQL_ROOT_PASSWORD=root mysql:5.7Copy the code

-d Background run container -p 3306:3306 Specify port mapping (host (host) port: container port) --name Specify a name for the container. -e Set the environment variable MYSQL_ROOT_PASSWORD=root Initial password mysql:5.7 Image name and versionCopy the code

Note: the -p parameter must be added to map the docker internal port, otherwise the docker internal port will be started and cannot be accessed from outside

Check whether the container is started

docker ps
Copy the code

Verify the connection

The connection was successful through the Navicat client

After installation, remote access can not do

1. Enter the mysql container

docker exec -it mysql57 bash
Copy the code

2, enter mysql, verify, prompt to log in, indicating in

3. Enter your account password:

mysql -uroot -p
Copy the code

show databases;
Copy the code

4. Switch database to mysql

use mysql
Copy the code

Select * from user where user = user

select user,host from user;
Copy the code

6, if the host of the account table does not have root is’ % ‘, then add a data from the command line. It can then be accessed through the client.