docker exec -it mysql bash
如果没有安装vim,请参考 解决Docker容器中不能用vim编辑文件
vim /etc/mysql/mysql.conf.d/mysql.cnf
加入如下配置
[mysql] default-character-set = utf8 [mysql.server] default-character-set = utf8 [mysqld_safe] default-character-set = utf8 [client] default-character-set = utf8 [mysqld] character_set_server=utf8 init_connect='SET NAMES utf8'
然后 ctrl +d 退出容器
最后docker restart mysql即可