1. 创建数据存储目录
先创建3个目录,创建MySQL容器时会挂载容器的卷。
mkdir log
mkdir data
mkdir conf
2. Docker仓库查看MySQL
3. 拉取镜像
docker pull mysql:5.7
4.创建MySQL配置文件
[client]
default-character-set=utf8mb4
[mysql]
default-character-set=utf8mb4
[mysqld]
init_connect="SET collation_connection = utf8mb4_unicode_ci"
init_connect="SET NAMES utf8mb4"
character-set-server=utf8mb4
collation-server=utf8mb4_unicode_ci
skip-character-set-client-handshake
skip-name-resolve
5.启动MySQL
docker run -p 3306:3306 --name mysql \
-v /usr/local/mysql/log:/var/log/mysql \
-v /usr/local/mysql/data:/var/lib/mysql \
-v /usr/local/mysql/conf:/etc/mysql/conf.d \
--restart=always \
-e MYSQL_ROOT_PASSWORD=123456 \
-d mysql:5.7
6.进入容器
docker exec -it mysql bash
标签:set,5.7,utf8mb4,MySQL,character,mysql,Docker
From: https://www.cnblogs.com/wyzstudy/p/18166013