Posted IT鑰佸摜
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了相关的知识,希望对你有一定的参考价值。
姝f枃濡備笅
璁板緱鍘诲勾鎴戝湪寰€MySQL瀛樺叆emoji琛ㄦ儏馃槻馃槼鏃讹紝涓€鐩村嚭閿欙紝鏃犳硶瀵煎叆銆傚悗鏉ユ壘鍒板姙娉?-- 閫氳繃鎶?utf8 鏀规垚 utf8mb4 灏卞彲浠ヤ簡锛屽苟娌℃湁娣辩┒銆?/p>
涓€骞村悗锛屾垜鐪嬪埌涓€绡囨枃绔犺鍒癳moji鏂囧瓧鍗?涓瓧鑺傦紝閫氬父瑕佺敤utf-8鍘绘帴鏀舵墠琛岋紝鍏朵粬缂栫爜鍙兘浼氬嚭閿欍€傛垜绐佺劧鎯冲埌鍘诲勾鎿嶄綔MySQL鎶妘tf8鏀规垚utf8mb4鐨勪簨鍎裤€?/p>
鍡紵浠栨湰韬笉灏辨槸utf8缂栫爜涔堬紒閭f垜褰撴椂杩樻敼涓敜瀛愶紵
闅鹃亾锛孧ySQL鐨剈tf8涓嶆槸鐪熸鐨刄TF-8缂栫爜鍚楋紵锛? 鍗фЫ杩欍€傘€侻ySQL鏈塨ug锛佸甫鐫€鐤戦棶鏌ヨ浜嗗緢澶氱浉鍏虫潗鏂欙紝鎵嶅彂鐜拌繖绔熺劧鏄疢ySQL鐨勪竴涓巻鍙查仐鐣欓棶棰榽~ 鎴戠瑧浜嗭紝娌℃兂鍒拌繖涔堢墰B鐨凪ySQL涔熶細鏈夎繖娈靛線浜嬨€?/p>
涓€銆佹姤閿欏洖椤?/span>
灏唀moji鏂囧瓧鐩存帴鍐欏叆SQL涓紝鎵ц insert 璇彞鎶ラ敊锛?/p>
INSERT INTO `csjdemo`.`student` (`ID`, `NAME`, `SEX`, `AGE`, `CLASS`, `GRADE`, `HOBBY`)
VALUES ('20', '鑰佸摜鍝ヰ煒?, '鐢?, '20', '181鐝?, '9骞寸骇', '鐪嬬墖鍎?);
[Err] 1366 - Incorrect string value: 'xF0x9Fx98x93' for column 'NAME' at row 1
鏀逛簡鏁版嵁搴撶紪鐮併€佺郴缁熺紪鐮佷互鍙婅〃瀛楁鐨勭紪鐮佹牸寮?鈫?utf8mb4 涔嬪悗锛屽氨鍙互浜嗭細
INSERT INTO `student` (`ID`, `NAME`, `SEX`, `AGE`, `CLASS`, `GRADE`, `HOBBY`)
VALUES (null, '鑰佸摜鍝ヰ煒擆煒?, '鐢?, '20', '181鐝?, '9骞寸骇', '鐪嬬墖鍎?);
浜屻€丮ySQL涓璾tf8鐨勮叮浜?/span>
MySQL 鐨勨€渦tf8鈥濆疄闄呬笂涓嶆槸鐪熸鐨?UTF-8銆?/p>
鍦∕ySQL涓紝鈥渦tf8鈥濈紪鐮佸彧鏀寔姣忎釜瀛楃鏈€澶氫笁涓瓧鑺傦紝鑰岀湡姝g殑 UTF-8 鏄瘡涓瓧绗︽渶澶氬洓涓瓧鑺傘€?/p>
鍦╱tf8缂栫爜涓紝涓枃鏄崰3涓瓧鑺傦紝鍏朵粬鏁板瓧銆佽嫳鏂囥€佺鍙峰崰涓€涓瓧鑺傘€?/p>
浣唀moji绗﹀彿鍗?涓瓧鑺傦紝涓€浜涜緝澶嶆潅鐨勬枃瀛椼€佺箒浣撳瓧涔熸槸4涓瓧鑺傘€傛墍浠ュ鑷村啓鍏ュけ璐ワ紝搴旇鏀规垚utf8mb4銆?/p>
濡備笂鍥句腑鎵€绀猴紝杩欐槸缂栫爜鏀规垚utf8mb4鍚庡叆搴撶殑鏁版嵁锛屽ぇ瀹跺彲浠ユ竻鏅扮殑瀵规瘮涓€涓嬫墍鍗犵殑瀛楃鏁般€佸瓧鑺傛暟銆傛鍥犲姝わ紝4瀛楄妭鐨勫唴瀹瑰線utf8缂栫爜涓彃鍏ワ紝鑲畾鏄笉琛岀殑锛屾彃涓嶈繘鍘诲晩锛屾槸鍚э紙澶ф綐鎽婃墜锛夈€?br>