1、创建文件
mkdir mysql && cd mysql
2. 挂载目录
在/root 目录下新建目录docker-compose,在/root/docker-compose目录下新建mysql文件件
mkdir config && cd config
vim my.cnf
将下面的配置文件复制到 my.cnf中
[mysqld]
user=mysql
default-storage-engine=INNODB
character-set-server=utf8
[client]
default-character-set=utf8
[mysql]
default-character-set=utf8
3.docker-compose.yml
vim docker-compose.yml
加下面内容复制到 docker-compose.yml 中
version: '3'
services:
mysql:
image: mysql
restart: always
container_name: mysql
environment:
MYSQL_ROOT_PASSWORD: yourpassword
TZ: Asia/Shanghai
ports:
- 3306:3306
volumes:
- ./data:/var/lib/mysql
- ./config/my.cnf:/etc/mysql/my.cnf
command:
--max_connections=1000
--character-set-server=utf8mb4
--collation-server=utf8mb4_general_ci
--default-authentication-plugin=mysql_native_password
MYSQL_ROOT_PASSWORD mysql root 账号登录的密码
评论区