Linux下MySql插入漢字報錯解決(/etc/my.cnf不存在) 看了很多帖子,大多數是說修改my.cnf,如 http://www.BkJia.com/database/201303/196824.html 可是我的這個文件不存在,難道是用rpm安裝的緣故。還有人說cp /usr/share/my-huge.cnf /etc/my.cnf 遺憾的是這個my-huge的文件都麼有。 找了半天終於摸索出解決問題的辦法了: 登陸到mysql,輸入命令:show variable like '%character%'; 得到的結果: 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/ | +--------------------------+----------------------------+ 8 rows in set (0.00 sec) 另外就是mysql> set names utf8; 在創建數據庫的時候指定編碼方式: create database yan2 default character set utf8。就可以在varchar()字段裡寫漢字了。