# MySQL单机
# 关键字说明
- 绿色字体代表已完成
- 红色字体代表待完成
# 实验明细
- 配置
- 运行
- 集成
# docker-compose.yaml
# 可参考: https://hub.docker.com/_/mysql
version: '3'
services:
mysql:
# image: registry.cn-shanghai.aliyuncs.com/odboy/ops:mysql-5.5.62
# image: registry.cn-shanghai.aliyuncs.com/odboy/ops:mysql-5.6.51
# image: registry.cn-shanghai.aliyuncs.com/odboy/ops:mysql-5.7.44
image: registry.cn-shanghai.aliyuncs.com/odboy/ops:mysql-8.0
container_name: mysql8-standalone
restart: unless-stopped
volumes:
- "./mysql/my.cnf:/etc/mysql/my.cnf"
- "./mysql/data:/var/lib/mysql"
- "./mysql/mysql-files:/var/lib/mysql-files"
environment:
TZ: Asia/Shanghai
LANG: en_US.UTF-8
MYSQL_ROOT_PASSWORD: root # 设置root用户密码
MYSQL_DATABASE: demo # 初始化的数据库名称
privileged: true
user: root
ports:
- "13306:3306"
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
# my.cnf
# 服务端参数配置
[mysqld]
user=mysql # MySQL启动用户
default-storage-engine=INNODB # 创建新表时将使用的默认存储引擎
character-set-server=utf8mb4 # 设置mysql服务端默认字符集
collation-server=utf8mb4_general_ci # 数据库字符集对应一些排序等规则,注意要和character-set-server对应
default-authentication-plugin=mysql_native_password
max_connections=1000 # 允许最大连接数
max_connect_errors=100 # 最大错误连接数
[mysql]
default-character-set=utf8mb4
[client]
default-character-set=utf8mb4 # 设置mysql客户端默认字符集
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
← Minio集群 Zookeeper单机 →