搜索了不少资料,都不起作用,还是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
[mysqld]
collation-server = utf8_unicode_ci
init-connect='SET NAMES utf8'
character-set-server = utf8
  1. Restart MySQL.
  2. For making sure, your MySQL is UTF8, Run the following queries in your MySQL prompt:
  • First query:
mysql> show variables like'char%';
 mysql> show variables like'char%';