解決Mysql錯誤提示Illegal mix of collations (gbk_chinese_ci,IMPLICIT) and (utf8_general_ci,COERCIBLE)
阿新 • • 發佈:2018-11-03
今天在寫資料庫作業的時候,針對這個問題,我一直在找解決辦法,現在終於是被我解決了。
在網上看了很多辦法,把這些辦法串起來就是最終辦法了,可以不用重新安裝。
第一步:檢視mysql根目錄的my.ini是否修改成功
將 default-character-set=latin1 修改成 default-character-set=utf8
character-set-server=utf8 修改成 character-set-server=utf8
(修改儲存後,需要重啟mysql) 字元不同的話,需要修改成相同字元
set collation_connection = utf8_ general_ci(或utf8_unicode_ci) 第二步:輸入sql命令,檢視mysql字符集設定 mysql> show variables like "%char%"; +--------------------------+---------------------------------------------------------+
| Variable_name | Value |
+--------------------------+---------------------------------------------------------+
| character_set_client | utf8 |
| character_set_connection | utf8 |
| character_set_database | utf8 |
| character_set_filesystem | binary |
| character_set_results | utf8 |
| character_set_server | utf8 |
| character_set_system | utf8 |
| character_sets_dir | C:\Program Files\MySQL\MySQL Server 5.5\share\charsets\ |
+--------------------------+---------------------------------------------------------+
如果不是utf8格式,則需要修改成utf8。
sql命令:set character_set_client = utf8;
再檢視具體字元,輸入sql命令:show variables like "%coll%";
+----------------------+-----------------+
| Variable_name | Value |
+----------------------+-----------------+
| collation_connection | utf8_general_ci |
| collation_database | utf8_general_ci |
| collation_server | utf8_general_ci |
+----------------------+-----------------+ 字元不同的話,需要修改成相同字元
set collation_connection = utf8_ general_ci(或utf8_unicode_ci)
將 default-character-set=latin1 修改成 default-character-set=utf8
character-set-server=utf8 修改成
(修改儲存後,需要重啟mysql) 字元不同的話,需要修改成相同字元
set collation_connection = utf8_ general_ci(或utf8_unicode_ci) 第二步:輸入sql命令,檢視mysql字符集設定 mysql> show variables like "%char%"; +--------------------------+---------------------------------------------------------+
+--------------------------+---------------------------------------------------------+
| character_set_client | utf8 |
| character_set_connection | utf8 |
| character_set_database | utf8 |
| character_set_filesystem | binary |
| character_set_results | utf8 |
| character_set_server | utf8 |
| character_set_system | utf8 |
| character_sets_dir | C:\Program Files\MySQL\MySQL Server 5.5\share\charsets\ |
+--------------------------+---------------------------------------------------------+
| Variable_name | Value |
+----------------------+-----------------+
| collation_connection | utf8_general_ci |
| collation_database | utf8_general_ci |
| collation_server | utf8_general_ci |
+----------------------+-----------------+ 字元不同的話,需要修改成相同字元
set collation_connection = utf8_ general_ci(或utf8_unicode_ci)