安裝mysql
sudo apt-get install mysql-server
查看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的默認編碼
sudo gedit /etc/mysql/my.cnf
在[mysqld]
#
# * Basic Settings
#
下面加上
character_set_server=utf8
修改完成後保存然後重啟mysql
sudo /etc/init.d/mysql restart