Front-end pit database… (To learn mysql, you need to have a mysql database to learn)

I picked a few key points and summarized them

1. According to (baijiahao.baidu.com/s?id=166193…

2. Create the container and start it.

docker run -p 3306:3306 –name dockermysql 

-v /Users/zl/mysql/conf:/etc/mysql/conf.d

-v  /Users/zl/mysql/logs:/logs

-v /Users/zl/mysql/data:/var/lib/mysql

-e MYSQL_ROOT_PASSWORD=abcde -d mysql

Note:

Docker run -p 3306:3306 –name dockermysql // create a container named dockermysql and associate it with port 3306 on the host

– v/Users/zl/mysql/conf: / etc/mysql/conf. D / / keyword – v mapping conditions; Map the mysql configuration file

The left side of the colon (:) indicates the path of the configuration file on the docker, and the right side indicates the path of the configuration file on the local machine

– v/Users/zl/mysql/logs: / logs/mysql/mapping log file With a colon (:) on the left side of the said docker log file path, the right of the said the machine of the log file path

– v/Users/zl/mysql/data: / var/lib/mysql / / mapping library database files, tables, (:) on the left side of the said docker on the path of the database file, database file path to the right of the said machine

-e MYSQL_ROOT_PASSWORD=abcde -d mysql // -e indicates to configure the environment variable keyword and the environment variable MYSQL_ROOT_PASSWORD=abcde of the mysql database

Docker start dockermysql // Run dockermysql

Docker ps // check the startup status and directory mapping result

Docker stop dockermysql // stop dockermysql

6, Connect to database (Navicat connection data)