docker-compose mysql5.7安装
FCAT 2020/8/2 mysqldocker-compose
构建环境:docker、docker-compose
# 配置文件
vim /docker/docker-compose.yml
version: "3.9"
services:
mysql5.7:
image: mysql:5.7
container_name: mysql5.7
ports:
- "3308:3306"
environment:
MYSQL_DATABASE: elock
MYSQL_ROOT_PASSWORD: 123456
MYSQL_ROOT_HOST: '%'
TZ: Asia/Shanghai
restart: always
volumes:
- /etc/localtime:/etc/localtime
- ./mysql5.7/conf:/etc/mysql/conf.d
- ./mysql5.7/data:/var/lib/mysql
- ./mysql5.7/log:/var/log
deploy:
resources:
limits:
memory: 2048M
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
# 配置my.conf
vim /docker/mysql/conf/my.cnf
[mysql]
default-character-set=utf8
socket=/var/lib/mysql/mysql.sock
[mysqld]
#修改大小写敏感
skip-grant-tables
lower_case_table_names=1
#mysql5.7以后的不兼容问题处理
sql_mode=NO_ENGINE_SUBSTITUTION,STRICT_TRANS_TABLES
datadir=/var/lib/mysql
socket=/var/lib/mysql/mysql.sock
# Disabling symbolic-links is recommended to prevent assorted security risks
symbolic-links=0
#允许最大连接数
max_connections=200
#服务端使用的字符集默认为8比特编码的latin1字符集
character-set-server=utf8
#创建新表时将使用的默认存储引擎
default-storage-engine=INNODB
lower_case_table_names=1
max_allowed_packet=16M
[mysqld_safe]
log-error=/var/log/mariadb/mariadb.log
pid-file=/var/run/mariadb/mariadb.pid
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
# 运行
docker up -d
1