docker-compose mysql5.6安装
FCAT 2020/8/2 mysqldocker-compose
构建环境:docker、docker-compose
# 配置文件
vim /docker/docker-compose.yml
version: "3.9"
services:
mysql:
image: mysql:5.6.50
container_name: mysql
ports:
- "3307:3306"
environment:
MYSQL_DATABASE: elock
MYSQL_ROOT_PASSWORD: 123456
MYSQL_ROOT_HOST: '%'
TZ: Asia/Shanghai
restart: always
volumes:
- /etc/localtime:/etc/localtime
- ./mysql/conf:/etc/mysql/conf.d
- ./mysql/data:/var/lib/mysql
- ./mysql/log:/var/log
deploy:
resources:
limits:
memory: 2048M
networks:
default:
external:
name: mynetwork
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
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
# 配置my.conf
vim /docker/mysql/conf/my.cnf
[mysqld]
user=mysql
datadir=/var/lib/mysql
character-set-server = utf8
lower_case_table_names = 1
log-error=/var/log/mysql.log
innodb_log_file_size = 256M
symbolic-links=0
socket=/var/lib/mysql/mysql.sock
port=3306
wait_timeout = 31536000
interactive_timeout = 31536000
max_connections = 1000
key_buffer_size = 3840M
thread_concurrency = 20
innodb_buffer_pool_size = 1024M
innodb_log_buffer_size = 20M
query_cache_size = 256M
read_buffer_size = 32M
sort_buffer_size = 32M
read_rnd_buffer_size = 32M
thread_cache_size = 64
join_buffer_size = 32M
tmp_table_size = 256M
sql_mode=STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION
[mysqld_safe]
log-error=/var/log/mysqld.log
pid-file=/var/run/mysqld/mysqld.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
28
29
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
28
29
# 运行
docker network create mynetwork
docker up -d
1
2
2