ERROR 1366 (HY000): Incorrect string value: '\xA6' for column 'jy_message' at row 1
這個問題是字符集導致的
檢視資料庫字符集
mysql> show variables like 'character%';
+--------------------------+-----------------------------------------+
| Variable_name | Value |
+--------------------------+-----------------------------------------+
| character_set_client | gbk |
| character_set_connection | gbk |
| character_set_database | gbk |
| character_set_filesystem | binary |
| character_set_results | gbk |
| character_set_server | gbk |
| character_set_system | utf8 |
| character_sets_dir | /export/servers/mysql56/share/charsets/ |
+--------------------------+-----------------------------------------+
8 rows in set (0.00 sec)
由於資料庫字符集為GBK,那麼如果插入報錯,說明插入的資料為UTF-8的
解決思路:
1、將表字符集更改為UTF-8
ALTER TABLE OLD_TABLE CONVERT TO CHARACTER SET charset_name [COLLATE collation_name]直接對整個表操作。
2、利用navicate匯入資料,
編碼設定為UTF-8即可