linux mysql 中文乱码的问题

搜索了不少资料,都不起作用,还是stackoverflow上的一位老兄的建议解决了我的问题,见:http://stackoverflow.com/questions/3513773/change-mysql-default-character-set-to-utf8-in-my-cnf

在上面网址对应的页面中,有图有真相;

我就摘抄几行:

-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

Then your configuration file ('/etc/my.cnf' for example) should look like that:(但是不一定就是在/etc/my.cnf这个目录里,我的就是/etc/mysql/my.cnf文件)

  1. Remove that directive and you should be good.

  2. Then your configuration file ('/etc/my.cnf' for example) should look like that:

    [mysqld]
    collation-server = utf8_unicode_ci
    init-connect='SET NAMES utf8'
    character-set-server = utf8
  3. Restart MySQL.

  4. For making sure, your MySQL is UTF8, Run the following queries in your MySQL prompt:

    • First query:

       mysql> show variables like'char%';
以下内容见http://stackoverflow.com/questions/3513773/change-mysql-default-character-set-to-utf8-in-my-cnf,粘贴复制也是很麻烦的


原文地址:https://www.cnblogs.com/passer1991/p/3515027.html