开发者学堂课程【SpringBoot快速掌握 - 核心技术:Docker安装MySQL 】学习笔记,与课程紧密联系,让用户快速学习知识。
课程地址:https://developer.aliyun.com/learning/course/612/detail/9271
Docker安装MySQL
一、安装MySQL示例
docker pull mysql
1.错误的启动:
[ root@localhost ~]# docker run --name mysql01-d mysql
42f09819908bb72dd99ae19e792e0a5d03c48638421fa64cce5f8ba0f40f5846
mysql
退出了
5 [root@localhost ~]# docker ps -a6 CONTAINER ID
IMAGE
COMMAND
CREATED
STATUS
PORTS
NAMES
42f09819908b
mysql
"docker-entrypoint.sh"34 seconds ago
Exited
(1)33 seconds ago
mysql01
538bde63e508
tomcat
"catalina.sh run"
About an hour ago Exited
(143) About an hour ago
compassionate_
goldstine
c4f1ac60b3fc
tomcat
"catalina.sh run"
About an hour ago Exited
(143) About an hour ago
lonely_fermi
181ec743a5271tomcat
"catalina.sh run"
About an hour ago Exited
(143)About an hour ago
sick_ramanujan
//错误日志
[root@localhost ~]# docker logs 42f09819908b
error: database is uninitialized and password option is not specified
You need to specify one of MYSQL_ROOT_PASSWORD,MYSQL_ALLOM_ENPTY_PASSMORD andMYSQL_RANDOM_ROOT_PASSWORD
2.正确的启动:
1)[root@localhost ~]# docker run --name mysql01 -e MYSQL_RO0T_PASSMORD-123456 -d mysql
2)b874c56bec49fb4302463805ab51e9097da779f2f572c22c695305dedd684c5f
3)[root@localhost ~]# docker ps
4)cONTAINER ID
IMAGE
CONMMAND
CREATED
STATUS
PORTS
NAMES
5)b874c56bec49
mysql
"docker-entrypoint.sh"4 seconds ago
Up 3
seconds
3306/tcp
mysql01
3.几个其他的高级操作:
docker run--name mysql03 -v/conf/mysql:/etc/mysql/conf.d -e MYSQL_ROOT_PASSwORD=my-secret-pw
-d mysql:tag
把主机的 /my/custom 文件夹挂载到 mysqldocker 容器的 /etc/mysq1/conf.d 文件夹里面3改 mysq1 的配置文件就只需要把mysql 配置文件放在
docker run --name some-mysql -e MYSQL_RO0T_PASSMORD=my-secret-pw -d mysql:tag --character-set-server=utf8mp4--collation-server=utf8mb4_unicode_ci
指定 mysql 的一些参数