# 1 :先创建挂载文件夹
mkdir -p /mysql/config ; mkdir -p /mysql/data ; mkdir -p /mysql/logs
# 2: 创建配置文件
vim /mysql/config/my.cnf
# 3: 修改权限
chmod 777 /mysql/config/my.cnf
# 4: 添加以下参数
# event_scheduler=ON 表示开启事件支持
# lower_case_table_names=1 表示数据库不区分大小写
# default-time-zone = '+8:00' 表示使用中国时区
[mysqld]
user=mysql
character-set-server=utf8
default_authentication_plugin=mysql_native_password
secure_file_priv=/var/lib/mysql
expire_logs_days=7
sql_mode=STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_ENGINE_SUBSTITUTION
max_connections=1000
event_scheduler=ON
lower_case_table_names=1
default-time-zone = '+8:00'
[client]
default-character-set=utf8
[mysql]
default-character-set=utf8
# 5:docker中的mysql容器
docker run -p 3306:3306 \
--name 名称 \
-e MYSQL_ROOT_PASSWORD=数据库密码 \
-v /mysql/config/my.cnf:/etc/mysql/my.cnf \
-v /mysql/logs:/logs \
-v /mysql/data/mysql:/var/lib/mysql \
--privileged=true \
-d 容器ID
标签:logs,配置文件,default,cnf,mysql,Docker,my
From: https://www.cnblogs.com/wanghong1994/p/17731143.html