当前位置: 代码迷 >> 综合 >> docker-compose 安装 mysql8
  详细解决方案

docker-compose 安装 mysql8

热度:64   发布时间:2023-11-09 17:43:51.0

目录

[root@meta mysql]# tree -L 2
.
├── conf
│   └── my.cnf
├── data
├── log
├── mysql-files
└── mysql.yml

docker-compose 文件

version: '3'
services:db:image: mysql:8.0container_name: mysqlrestart: alwaysprivileged: trueuser: rootcommand:--default-authentication-plugin=mysql_native_password--character-set-server=utf8mb4--collation-server=utf8mb4_general_ci--explicit_defaults_for_timestamp=trueenvironment: MYSQL_ROOT_PASSWORD: adminports:- 3306:3306volumes: - ./data:/var/lib/mysql:rw- ./conf/my.cnf:/etc/mysql/my.cnf:rw- ./log:/var/log/mysql:rw- ./mysql-files:/var/lib/mysql-files:rw

mysql8 配置文件( my.cnf )


[mysqld]
pid-file        = /var/run/mysqld/mysqld.pid
socket          = /var/run/mysqld/mysqld.sock
datadir         = /var/lib/mysql
secure_file_priv=/var/lib/mysql-filescharacter-set-server=utf8
default_authentication_plugin=mysql_native_password
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[client]
default-character-set=utf8[mysql]
default-character-set=utf8