手记

Ubuntu15下mysql5.6.25不支持中文的解决办法

apt-get install 安装的,不是源码包安装的mysql

1 修改mysql的配置文件

/etc/mysql/conf.d/mysql.cnf

在[mysql]的下方加入如下语句:(注:这个文件下没有配置,只有【mysql】)

no-auto-rehash
default-character-set=utf8

/etc/mysql/mysql.conf.d/mysqld.cnf

在[mysqld]下加入

socket = /var/run/mysqld/mysqld.sock
port = 3306
character-set-server=utf8 (这里是server,之前有的版本是set)

重启mysql: sudo /etc/init.d/mysql restart

查看字符集

mysql> show variables like '%char%';
+--------------------------+----------------------------+
| Variable_name            | Value                      |
+--------------------------+----------------------------+
| character_set_client     | utf8                       |
| character_set_connection | utf8                       |
| character_set_database   | utf8                       |
| character_set_filesystem | binary                     |
| character_set_results    | utf8                       |
| character_set_server     | utf8                       |
| character_set_system     | utf8                       |
| character_sets_dir       | /usr/share/mysql/charsets/ |
+--------------------------+----------------------------+
8 rows in set (0.00 sec)

 设置之后如果之前的数据库已经创建了,只能删除重新创建了。

0人推荐
随时随地看视频
慕课网APP