1.Docker 中修改 docker-compose.yaml
version: '3'
services:
mysql:
container_name: mysql5.7
image: mysql:5.7.33
ports:
- "3306:3306"
environment:
MYSQL_ROOT_PASSWORD: "123456"
MYSQL_USER: 'user'
MYSQL_PASS: 'user123456'
restart: always
volumes:
- "./db:/var/lib/mysql"
- "./conf/my.cnf:/etc/my.cnf"
- "./init:/docker-entrypoint-initdb.d/"
deploy:
resources:
limits:
cpus: '0.4'
memory: 200M
# reservations:
#cpus: '0.2'
#memory: 200M
2. 同目录下 conf 中的 mysql 的 my.conf 中修改配置
[client]
default-character-set=utf8
#character-set-server=utf8
#mysqlde utf8字符集默认为3位的,