Run Mysql8 Docker on Mac
准备工作
1
2
3
4
5
| install docker on mac
docker pull mysql:8.4.2
#/etc/mysql/conf.d/enable-mysql-native-password.cnf
mkdir -p /data/docker_data/mysql8/{data,logs,conf,bin,docker-entrypoint-initdb.d,conf/conf.d/}
|
配置文件
/etc/mysql/conf.d/enable-mysql-native-password.cnf
1
2
3
| # Enable mysql_native_password plugin
[mysqld]
mysql_native_password=ON
|
数据库初始化文件
将数据库初始化 sql 或命令行文件放在此处
/data/docker_data/mysql8/docker-entrypoint-initdb.d
启动 docker
1
2
3
4
5
6
7
8
9
10
11
12
13
| dir=/data/docker_data/mysql8
dbname=222
rootpsw=111
docker run -p 3306:3306 --name mysql8 \
--privileged=true \
--restart unless-stopped \
-e MYSQL_ROOT_PASSWORD=$rootpsw \
-e MYSQL_DATABASE=$dbname \
-v $dir/conf:/etc/mysql \
-v $dir/docker-entrypoint-initdb.d:/docker-entrypoint-initdb.d \
-v $dir/logs:/logs \
-v $dir/data:/var/lib/mysql \
-d mysql:8.4.2
|