Installation environment, CentOS Linux version 3.10.0-514.el7.x86_64
1. Find the latest MySQL image
Docker search MySQL
2, download the latest mysql-server image
Docker pull Mysql/mysql-server:latest 3, after the download is complete, you can view the downloaded image Docker images 4, build container, the-e command to set the default password,--name can customize the name of the image Docker run-- Name Mysql-p 3306:3306-e mysql_root_password=123456-d mysql/mysql-server:latest 5, you can view the generated container Docker Ps-a 6, start the container docker s Tart MySQL 7, running commands in containers Docker exec-it MySQL bash in addition, after starting the service, use the external environment to access CentOS 3306 port hint 1130 error, is because the root account of MySQL only has access to the local account using the Docker exec-it MySQL bash command into the MySQL command line operating environment use Mysqlshow tables;--can see the user's datasheet select host From user where user = ' root ';--you can see that host is localhostupdate user set host = '% ' where user = ' root '; flush privileges;--Update Permission control You can then access MySQL using the external environment's database software.
Install MySQL server image under Docker