标签: 乱码

linux下mysql编码配置

1 修改/etc/mysql/my.cnf配置文件 增加default-character-set=utf8

配置文件如下

[java]
[client]

port = 3306
socket = /var/run/mysqld/mysqld.sock
default-character-set=utf8
# Here is entries for some specific programs
# The following values assume you have at least 32M ram

# This was formally known as [safe_mysqld]. Both versions are currently parsed.
[mysqld_safe]
socket = /var/run/mysqld/mysqld.sock
nice = 0

[mysqld]
#
# * Basic Settings
#
default-storage-engine=INNODB
character-set-server=utf8
collation-server=utf8_general_ci
[/java]

2 重启mysql

sudo service mysql restart