安装和启动
mkdir -p /data/mysql/{data,conf}
cd /data/
# 准备源数据库
cat > mysql/conf/my.cnf << EOF
[client]
default-character-set=utf8
[mysql]
default-character-set=utf8
[mysqld]
init_connect='SET collation_connection = utf8_unicode_ci'
init_connect='SET NAMES utf8'
character-set-server=utf8
collation-server=utf8_unicode_ci
skip-character-set-client-handshake
skip-name-resolve
# 开启binlog
server-id=1
log-bin=/var/lib/mysql/mysql-bin
EOF
docker run --name mysql -d --restart=always \
-p 3306:3306 \
-v /data/mysql/conf:/etc/mysql/conf.d/ \
-v /data/mysql/data:/var/lib/mysql \
-e MYSQL_ROOT_PASSWORD=85bUSQ3JjL5nQzIo \
registry.cn-hangzhou.aliyuncs.com/hlcen/mysql:8.0
评论区