Docker 安装 MySQL5.7

转自:https://www.cnblogs.com/418836844qqcom/p/11692237.html

 

1.安装mysql5.7 docker镜像:

docker pull mysql:5.7

2.查看镜像库:

docker images

3. 在本地创建mysql的映射目录 

mkdir -p /root/mysql/data  /root/mysql/conf  /root/mysql/logs

 4.在/root/mysql/conf中创建  mysqld.cnf文件,并添加配置文件内容

cd   /root/mysql/conf
vi   mysqld.cnf
Docker 安装 MySQL5.7
[client]
default-character-set=utf8
 
[mysql]
default-character-set=utf8
 
[mysqld]
pid-file        = /var/run/mysqld/mysqld.pid
socket          = /var/run/mysqld/mysqld.sock
datadir         = /var/lib/mysql
#log-error      = /var/log/mysql/error.log
# By default we only accept connections from localhost
#bind-address   = 127.0.0.1
# Disabling symbolic-links is recommended to prevent assorted security risks
symbolic-links=0
lower_case_table_names=1
 
init_connect='SET collation_connection = utf8_general_ci'
init_connect='SET NAMES utf8'
character-set-server=utf8
collation-server=utf8_general_ci
 
max_connections = 1000
Docker 安装 MySQL5.7

 

5.创建容器,将数据,日志,配置文件映射到本机

 

docker run --name mysql -p 3306:3306 --restart=always -e MYSQL_ROOT_PASSWORD=root  -v /root/mysql/conf/mysqld.cnf:/etc/mysql/mysql.conf.d/mysqld.cnf -v /root/mysql/data:/var/lib/mysql   -v /root/mysql/log:/var/log/mysql  -d  mysql:5.7 

上一篇:西门子1200PLC的MODBUS_RTU轮询程序, 代码成熟,已经运用在多个项目中,自己用SCL语言编写


下一篇:mysql 8 设置大小写不敏感