如何用docker部署一个mysql

2024-12-25 09:18:40
推荐回答(1个)
回答1:

1 docker pull mysql
2 docker run -v /data/var/mysql/:/var/lib/mysql -e YSQL_ROOT_PASSWORD=kS4pJUIb mysql
3 docker stop [CONTAINER ID]
4 docker run -it -v /data/var/mysql/:/var/lib/mysql mysql /bin/bash
5 mysqld_safe&
6 grant all privileges on *.* to 'wuxiao'@'%' identified by 'password';
7 docker cp [CONTAINER ID]:/etc/mysql/my.cnf /data/local/my.cnf
8 docker stop [CONTAINER ID]
9 docker run -d -p 3306:3306 -v /data/var/mysql/:/var/lib/mysql -v /data/local/my.cnf:/etc/mysql/my.cnf mysql
10 add [CMD] to /etc/rc.local
11 OK!