# 解决Docker中运行的MySQL中文乱码

docker exec -it mysql bash
1

# 解决Docker容器中不能用vim编辑文件

更新源

apt-get update
1

安装vim

apt-get install -y vim
1

编译mysql.cnf配置文件

vim /etc/mysql/mysql.conf.d/mysql.cnf
1

加入如下配置

[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'
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
上次更新: 2 years ago