1.首先停止MySQL服务:sudo /etc/init.d/mysql stop

2.然后编辑MySQL配置文件:sudo gedit /etc/mysql/my.cnf

在my.cnf文件中的[client]段下面加入

default-character-set=utf8
[mysqld_safe]
default-character-set=utf8
[mysqld]
default-character-set=utf8
[mysql]
default-character-set=utf8

重新启动MySQL服务,

sudo /etc/init.d/mysql start