- 官方镜像
- 安装
docker pull docker.io/mysql - 启动容器
docker run --name mysql -p 3306:3306 -e MYSQL_ROOT_PASSWORD=1qazxsw2 -d mysql:latest - 命令行输入
mysql
报错:ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/tmp/mysql.sock' (2) - 进入mysql容器
docker exec -it mysql bash
把文件复制到容器,在容器登录(指定utf8要不中文乱码)mysql -u root -p --default-character-set=utf8
登录并执行source abc.sql
docker run -p 3306:3306 --name mysql -v $PWD/conf/my.cnf:/etc/mysql/my.cnf -v $PWD/logs:/logs -v $PWD/data:/mysql_data -e MYSQL_ROOT_PASSWORD=1qazxsw2 -d mysql:latest
报错了
/usr/bin/docker-current: Error response from daemon: invalid header field value "oci runtime error: container_linux.go:247: starting container process caused "process_linux.go:359: container init caused \"rootfs_linux.go:54: mounting \\\"/alidata/docker/mysql/conf/my.cnf\\\" to rootfs \\\"/var/lib/docker/devicemapper/mnt/acdbb966c6c792749c0f8ae5cf1dd93bf52470a88bd83c3f05777b8151220703/rootfs\\\
z" at \\\"/var/lib/docker/devicemapper/mnt/acdbb966c6c792749c0f8ae5cf1dd93bf52470a88bd83c3f05777b8151220703/rootfs/etc/mysql/mysql.cnf\\\" caused \\\"not a directory\\\"\""\n".
参考http://www.docker.org.cn/thread/13.html
- 国内daocloud镜像
docker pull daocloud.io/library/mysql:5.7
Trying to pull repository daocloud.io/library/mysql ...
5.7: Pulling from daocloud.io/library/mysql
693502eb7dfb: Pull complete
08d0e9d74b1b: Pull complete
e700ebfbe6bc: Pull complete
f718f1976629: Pull complete
575a0830e278: Pull complete
8461dfcf361d: Pull complete
349434898dfb: Pull complete
78d351522443: Pull complete
21897ab46952: Pull complete
ca6ffbbedc10: Pull complete
ba8ff064032b: Pull complete
Digest: sha256:cd3b13f2a52d933ec6428911a500040167be2740cf687e9714c8b50df208c4f3
docker run -p 3306:3306 --name mymysql -v $PWD/conf/my.cnf:/etc/mysql/my.cnf -v $PWD/logs:/logs -v $PWD/data:/mysql_data -e MYSQL_ROOT_PASSWORD=1qazxsw2 -d mysql:5.7
cd3b13f2a52d933ec6428911a500040167be2740cf687e9714c8b50df208c4f3
网友评论