docker-compose.yml
version: '3.8'
services:
mysql:
image: mysql:8.0.27
restart: always
container_name: mysql8
volumes:
- './datadir:/var/lib/mysql'
- './my.cnf:/etc/mysql/my.cnf'
- './my.conf.d:/etc/mysql/conf.d'
- './mysql-files:/var/lib/mysql-files'
- './logs:/var/log/mysql'
#- ./sql:/docker-entrypoint-initdb.d #数据库自动导入
ports:
- "3306:3306"
#expose:
# - "3306"
command:
--default-authentication-plugin=mysql_native_password
--max_connections=1000
#command:
# /bin/bash -c "chmod 644 /etc/mysql/conf.d/*.cnf && chmod 644 /etc/mysql/my.cnf"
#/bin/bash -c "redis-server /usr/local/etc/redis/redis.conf"
#privileged:true
environment:
#- SET_CONTAINER_TIMEZONE=true
#- CONTAINER_TIMEZONE=Asia/Shanghai
- TZ=Asia/Shanghai
- MYSQL_ROOT_PASSWORD=example
- MYSQL_USER=lren
- MYSQL_PASS=lren
修改时区方法
[mysqld]
default-time_zone = '+8:00'
错误:[Warning] World-writable config file '/etc/mysql/my.cnf' is ignored.
处理 chmod 644 /etc/mysql/my.cnf
处理 chmod 644 /etc/mysql/conf.d/*.cnf