Docker builds MySQL

  1. Docker download image (download version 5.7 this time)

docker pull mysql:5.7

  

  Second, use Docker to start MySQL

docker run -d -p 3306:3306 --name master-mysql -e MYSQL_ROOT_PASSWORD=123456 mysql:5.7

  -d run in the background

  -p port corresponding

  Use -e MYSQL_ROOT_PASSWORD=123456 to set the database password

  followed by the image name and version number at the end

  

  Three, log in to MySQL

mysql -uroot -p123456 -h 10.13.70.222 -P3307

  PS: -h The host name needs to have spaces, otherwise the login will report an error

 

  Fourth, the configuration file and data file location

/etc/mysql/mysql.conf.d/mysqld.cnf #Configuration file location

  PS: You can use -v to mount data files, bin-log files and logs

    You can copy the location file through the docker cp command, modify it and then copy it back.

    After modifying the configuration file, restart the container with the following command

docker stop master-mysql
docker start master-mysql

  

 

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=324946804&siteId=291194637