- 下载mysql镜像
docker pull mysql:5.6
- 运行镜像
- windows
docker run -d --privileged=true --name mysql-test -v //e/ProgramData/docker:/var/lib/mysql -e MYSQL_ROOT_PASSWORD=123456 -p 33306:3306 mysql:5.6
*mac
docker run -d --privileged=true --name mysql-test -v /Users/tangx/Documents/mysql/statistic:/var/lib/mysql -e MYSQL_ROOT_PASSWORD=123456 -p 33306:3306 mysql:5.6
- 解决外网不能访问数据库的问题
docker exec -it mysql-test bash
mysql>show databases;
mysql>use mysql;
mysql>select host from user where user='root' AND host='localhost';
mysql>update user set host='%' where user='root' AND host='localhost';
mysql>flush privileges;
网友评论