当前位置:网站首页>Docker installs MySQL 8.0. Detailed steps

Docker installs MySQL 8.0. Detailed steps

2022-06-24 22:21:00 Nice2cu_ Code

Docker install MySQL 8.0

One 、 Pull the mirror image

docker pull mysql:8.0.21

Two 、 Look at the mirror image

docker images
image-20210706082107138

3、 ... and 、 Run container

docker run -it -d --name mysql --net=host \
-m 500m -v /root/mysql/data:/var/lib/mysql \
-v /root/mysql/config:/etc/mysql/conf.d  \
-e MYSQL_ROOT_PASSWORD=abc123456 \
-e TZ=Asia/Shanghai mysql:8.0.21 \
--lower_case_table_names=1

Code meaning :

docker run -p Local host port number : Container service port number --name Container name [-e Configuration information modification ] -d Mirror name

  • conf.d Is the configuration file of the database
  • MYSQL_ROOT_PASSWORD Specify database password , The default account name is root
  • lower_case_table_names=1 Turn off case sensitivity for database names

Four 、 Check operation

docker ps
image-20210706082351917

5、 ... and 、 Into the container

docker exec -it mysql8.0 /bin/bash

6、 ... and 、 To configure MySQL

1. Get into MySQL

image-20210706082611524

2. Configure support for remote connections

ALTER USER 'root'@'%' IDENTIFIED WITH mysql_native_password BY 'MySQL Password ';
# Refresh database 
flush privileges;
image-20210706082706917
原网站

版权声明
本文为[Nice2cu_ Code]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/175/202206241615542144.html