来查看可用版本
sudo docker search mysql
拉取mysql镜像
docker pull mysql:5.7
mkdir -p /data/docker/mysql/conf && mkdir -p /data/docker/mysql/data
service docker restart
sudo docker ps -a
docker cp mysql-service:/etc/mysql/my.cnf /data/docker/mysql/conf
docker run --name mysql-server -p 3306:3306 -e MYSQL_ROOT_PASSWORD=app1234! --mount type=bind,src=/data/docker/mysql/conf/my.cnf,dst=/etc/mysql/my.cnf --mount type=bind,src=/data/docker/mysql/data,dst=/var/lib/mysql --restart=on-failure:3 -d mysql
docker exec -it mysql-server bash
mysql -u root -p
测试挂载
show variables like '%char%';
修改my.cnf
[mysqld]
character-set-server=utf8
[client]
default-character-set=utf8
[mysql]
default-character-set=utf8