docker-compose 部署单节点mysql8
1. docker-compose文件准备
- docker-compose-kpi.yml
version: "3.2"
services:
mysql:
image: mysql:8.0
restart: always
container_name: mysql
environment:
MYSQL_ROOT_PASSWORD: "admin123456"
TZ: "Asia/Shanghai"
ports:
- "13306:3306"
volumes:
- mysql-data:/var/lib/mysql
- mysql-conf:/etc/mysql
command:
--max_connections=1000
--character-set-server=utf8mb4
--collation-server=utf8mb4_general_ci
--default-authentication-plugin=mysql_native_password
deploy:
resources:
limits: # 资源使用上限
cpus: "1"
memory: 1G
volumes:
mysql-data:
mysql-conf:
2. 部署
docker-compose -f docker-compose-kpi.yml up -d
3. 创建自定义配置文件
- my.cnf
[mysqld]
user=mysql
default-storage-engine=INNODB
character-set-server=utf8
[client]
default-character-set=utf8
[mysql]
default-character-set=utf8
4. 重启容器
docker restart mysql
标签:compose,mysql8,character,default,set,mysql,docker
From: https://www.cnblogs.com/JentZhang/p/17216357.html