Variable_name | Value |
---|---|
character_set_client | utf8mb4 |
character_set_connection | utf8mb4 |
character_set_database | utf8mb4 |
character_set_filesystem | binary |
character_set_results | utf8mb4 |
character_set_server | utf8mb4 |
character_set_system | utf8 |
collation_connection | utf8mb4_unicode_ci |
collation_database | utf8mb4_unicode_ci |
collation_server | utf8mb4_unicode_ci |
collation_connection 、collation_database 、collation_server是什么沒關(guān)系。
但必須保證
系統(tǒng)變量 | 描述 |
---|---|
character_set_client | (客戶端來源數(shù)據(jù)使用的字符集) |
character_set_connection | (連接層字符集) |
character_set_database | (當(dāng)前選中數(shù)據(jù)庫的默認字符集) |
character_set_results | (查詢結(jié)果字符集) |
character_set_server | (默認的內(nèi)部操作字符集) |
這幾個變量必須是utf8mb4。
5. 數(shù)據(jù)庫連接的配置
數(shù)據(jù)庫連接參數(shù)中:
characterEncoding=utf8
會被自動識別為utf8mb4,也可以不加這個參數(shù),會自動檢測。
而autoReconnect=true
是必須加上的。
6. 將數(shù)據(jù)庫和已經(jīng)建好的表也轉(zhuǎn)換成utf8mb4
更改數(shù)據(jù)庫編碼:
更改表編碼:
如有必要,還可以更改列的編碼
7、在第3步設(shè)置character_set_database,character_set_server不成功的可以試下直接在mysql.exe下
set @@character_set_server='utf8mb4'; set @@character_set_database='utf8mb4';
這下數(shù)據(jù)庫就可以存下emoji表情的編碼了。
附上我的my.ini
# For advice on how to change settings please see # http://dev.mysql.com/doc/refman/5.6/en/server-configuration-defaults.html # *** DO NOT EDIT THIS FILE. It's a template which will be copied to the # *** default location during install, and will be replaced if you # *** upgrade to a newer version of MySQL. [client] default-character-set = utf8mb4 [mysql] default-character-set = utf8mb4 [mysqld] character-set-client-handshake = FALSE character-set-server = utf8mb4 collation-server = utf8mb4_unicode_ci init_connect='SET NAMES utf8mb4' # Remove leading # and set to the amount of RAM for the most important data # cache in MySQL. Start at 70% of total RAM for dedicated server, else 10%. # innodb_buffer_pool_size = 128M # Remove leading # to turn on a very important data integrity option: logging # changes to the binary log between backups. # log_bin # These are commonly set, remove the # and set as required. # basedir = ..... # datadir = ..... # port = ..... # server_id = ..... # Remove leading # to set options mainly useful for reporting servers. # The server defaults are faster for transactions and fast SELECTs. # Adjust sizes as needed, experiment to find the optimal values. # join_buffer_size = 128M # sort_buffer_size = 2M # read_rnd_buffer_size = 2M sql_mode=NO_ENGINE_SUBSTITUTION,STRICT_TRANS_TABLES
更多關(guān)于MySQL相關(guān)內(nèi)容感興趣的讀者可查看本站專題:《MySQL存儲過程技巧大全》、《MySQL常用函數(shù)大匯總》、《MySQL日志操作技巧大全》、《MySQL事務(wù)操作技巧匯總》及《MySQL數(shù)據(jù)庫鎖相關(guān)技巧匯總》
希望本文所述對大家MySQL數(shù)據(jù)庫計有所幫助。
標(biāo)簽:南陽 三門峽 商丘 貴州 巴中 揚州 新余 贛州
巨人網(wǎng)絡(luò)通訊聲明:本文標(biāo)題《mysql存儲emoji表情報錯的處理方法【更改編碼為utf8mb4】》,本文關(guān)鍵詞 mysql,存儲,emoji,表,情報,;如發(fā)現(xiàn)本文內(nèi)容存在版權(quán)問題,煩請?zhí)峁┫嚓P(guān)信息告之我們,我們將及時溝通與處理。本站內(nèi)容系統(tǒng)采集于網(wǎng)絡(luò),涉及言論、版權(quán)與本站無關(guān)。