Docker安装MySql-挂载外部数据和配置
http://www.fwhyy.com/2018/05/docker-installs-mysql-to-mount-external-data-and-configuration/
https://www.cnblogs.com/tangxuliang/p/9341271.html
docker run -d -p 3306:3306 --restart always --privileged=true --name dockermysql -e MYSQL_ROOT_PASSWORD=123456 -v=/root/dockermysql/config/my.cnf:/etc/my.cnf -v=/root/dockermysql/data:/var/lib/mysql -d mysql
[root@VM_0_5_centos dockermysql]# docker run -d -p 3306:3306 --restart always --privileged=true --name dockermysql -e MYSQL_ROOT_PASSWORD=123456 -v=/root/dockermysql/config/my.cnf:/etc/my.cnf -v=/root/dockermysql/data:/var/lib/mysql -d mysql fd03062b839069d29ffc4500b2c9ff96266893f77f7a778b749ecc6fd8cf11d9 [root@VM_0_5_centos dockermysql]# docker ps -a CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES fd03062b8390 mysql "docker-entrypoint.s…" 8 seconds ago Up 6 seconds 0.0.0.0:3306->3306/tcp, 33060/tcp dockermysql [root@VM_0_5_centos ~]# docker exec -it dockermysql bash root@fd03062b8390:/# mysql -u root -p Enter password: Welcome to the MySQL monitor. Commands end with ; or \g. Your MySQL connection id is 8 Server version: 8.0.16 MySQL Community Server - GPL Copyright (c) 2000, 2019, Oracle and/or its affiliates. All rights reserved. Oracle is a registered trademark of Oracle Corporation and/or its affiliates. Other names may be trademarks of their respective owners. Type 'help;' or '\h' for help. Type '\c' to clear the current input statement. mysql> show databases; +--------------------+ | Database | +--------------------+ | information_schema | | mysql | | performance_schema | | sys | +--------------------+ 4 rows in set (0.03 sec) mysql> grant all privileges on *.* to 'root'@'%' ; Query OK, 0 rows affected (0.04 sec) mysql> flush privileges; Query OK, 0 rows affected (0.01 sec) mysql> ALTER USER 'root'@'%' IDENTIFIED WITH mysql_native_password BY '123456'; Query OK, 0 rows affected (0.02 sec) mysql> exit; Bye
浙公网安备 33010602011771号