MySQL启动MySQL8.0并指定配置文件

MySQL启动MySQL8.0并指定配置文件

mkdir -p /mysql8hello/config ; 
mkdir -p /mysql8hello/data ; 
mkdir -p /mysql8hello/logs;
mkdir -p /mysql8hello/conf;
vim /mysql8hello/config/my.cnf;
# 启动报错就修改成777,但是会提示风险
chmod 644 /mysql8hello/config/my.cnf ;

添加:

# 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

启动命令

docker run -p 3312:3306 \
--name mysql8new \
--restart=always \
-e MYSQL_ROOT_PASSWORD=1234567 \
-v /mysql8hello/config/my.cnf:/etc/mysql/my.cnf \
-v /mysql8hello/logs:/logs \
-v /mysql8hello/data/mysql:/var/lib/mysql \
-v /mysql8hello/conf:/etc/mysql/conf.d \
--privileged=true \
-d mysql:8.0.21 

你可能感兴趣的:(MySQL,mysql,数据库)