Ubuntu15.10下mysql 5.6.28中文乱码问题

一、登录Mysql查看默认字符集设置:show variables like 'character%';

+--------------------------+----------------------------+
| Variable_name | Value |
+--------------------------+----------------------------+
| character_set_client | utf8 |
| character_set_connection | utf8 |
| character_set_database | latin1 |
| character_set_filesystem | binary |
| character_set_results | utf8 |
| character_set_server | latin1 |
| character_set_system | utf8 |
| character_sets_dir | /usr/share/mysql/charsets/ |
+--------------------------+----------------------------+
二、修改mysql中的配置文件

   1.在终端中:sudo gedit /etc/mysql/conf.d/mysql.cnf

     在[mysql]的下方加入如下语句:

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

    2.在终端中:sudo gedit /etc/mysql.conf.d/mysqld.cnf

       在[mysqld]下加入如下语句:

        character-set-server=utf8 

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

四、查看字符集

       mysql->show variables like 'character%';

+--------------------------+----------------------------+
| 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/ |
+--------------------------+----------------------------+

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

你可能感兴趣的:(mysql,ubuntu,乱码)