使用DockerFile
from mysql:5.7.17
COPY my.cnf /etc/mysql/conf.d/mysqlutf8.cnf
CMD ["mysqld", "--character-set-server=utf8", "--collation-server=utf8_unicode_ci"]
[client]
default-character-set=utf8
[mysql]
default-character-set=utf8
[mysqld]
collation-server=utf8_general_ci
character-set-server=utf8
init-connect='SET NAMES utf8'
使用docker容器
docker build -t mysql:5.7.17 .
docker run --name saas-mysql -p 3306:3306 -e MYSQL_ROOT_PASSWORD=123456 -d mysql:5.7.17
docker exec -i saas-mysql mysql -uroot -p123456 <<< "CREATE DATABASE IF NOT EXISTS zhg DEFAULT CHARSET utf8 COLLATE utf8_general_ci;"
docker exec -i saas-mysql mysql -uroot -p123456 -f zhg < /Users/lin/Downloads/zhg-2020-01-18.sql
查看字符集
docker exec -it saas-mysql bash
mysql -uroot -p123456
show variables like '%char%';
网友评论