## Docker中MySQL使用
- 准备目录
- test
- conf
- data
``` Bash
mkdir /Users/adong/docker/test/conf /Users/adong/docker/test/data
```
my.cnf 配置文件
``` Conf
[mysqld]
user=mysql
character-set-server=utf8
default_authentication_plugin=mysql_native_password
secure_file_priv=/var/lib/mysql
datadir=/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
default-time-zone='+8:00'
[client]
default-character-set=utf8mb4
[mysql]
default-character-set=utf8mb4
```
执行docker run 启动容器 映射 3309 为mysql8.0.13的连接端口
``` Bash
docker run \
--privileged=true \
-d --restart=always \
-v /Users/adong/docker/test/data/:/var/lib/mysql \
-v /Users/adong/docker/test/conf:/etc/mysql/conf.d \
-v /Users/adong/docker/test/conf:/etc/mysql/mysql.conf.d \
-p 3309:3306 \
--name mysql8_test \
-e MYSQL_ROOT_PASSWORD=123456 \
mysql:8.0.13
```
完成