docker容器内怎么连接外部的mysql
2个回答
展开全部
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!
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!
本回答被提问者采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询