1MySQL涓瓨鍏ユ暟鎹椂鍙戠敓鐨勭紪鐮佽浆鎹㈣繃绋嬶細
1銆佸湪缁堢 (Terminal锛屽彲浠ユ槸 bash 绐楀彛锛屼篃鍙互鏄鎴风宸ュ叿濡� navicat) 涓緭鍏ワ紝杈撳叆鐨勫唴瀹圭敱 Terminal 鏍规嵁鍏惰嚜宸辩殑瀛楃杩涜缂栫爜銆�
2銆佺粡 Terminal 缂栫爜鍚庣殑浜岃繘鍒舵祦琚紶杈撳埌 mysql server銆俶ysql server(mysql engine) 鏍规嵁鍙傛暟 character_set_client 鐨勫瓧绗﹁缃潵瀵硅浜岃繘鍒舵祦杩涜瑙g爜銆�
3銆佽В鐮佷箣鍚庯紝mysql server 鍐嶆鏍规嵁鐩殑琛紝鍗� table 鐨勫瓧绗﹂泦鏉ュ垽鏂槸鍚﹂渶瑕佸瓧绗︾紪鐮佽浆鎹€�傚鏋� character_set_client 鐨勫瓧绗﹁缃拰 table 瀹氫箟鏃剁殑 character 璁剧疆涓�鑷达紝鍒欐棤闇�瀛楃缂栫爜杞崲銆傚惁鍒欒繘琛岃浆鎹紝鐒跺悗灏嗚浆鎹㈠悗鐨勪簩杩涘埗娴佸瓨鏀惧埌鏁版嵁鏂囦欢 (file) 涓幓銆�
鎬荤粨锛歝lient ------> server(engine) -----> file 聽 聽 闇�瑕佺粡杩囦笁娆$紪鐮侊紝涓ゆ缂栫爜杞寲銆�
2MySQL聽涓彇鍑烘暟鎹椂鍙戠敓鐨勭紪鐮佽浆鎹㈣繃绋嬶細
1銆佷粠鏁版嵁鏂囦欢 (file) 涓鍑轰簩杩涘埗鏁版嵁娴侊紝灏嗚鏁版嵁娴佹牴鎹� table 瀹氫箟鏃剁殑 character 璁剧疆鏉ヨ繘琛岃В鐮併��
2銆佸湪鐢� table character 瀵逛簩绾у埗鏁版嵁娴佽繘琛岃В鐮佷箣鍚庯紝鍦� mysql engine(mysql server) 涓紝闇�瑕佹牴鎹弬鏁� character_set_client 鐨勫瓧绗﹂泦璁剧疆瀵硅В鐮佸悗鐨勬暟鎹簱娴佸啀涓�娆¤繘琛岀紪鐮侊紝灏嗙紪鐮佷箣鍚庣殑浜岀骇鍒舵暟鎹簱娴佷紶杈撳埌 client 绔��
3銆乧lient 绔紝鍗崇粓绔� (Terminal) 鏍规嵁鍏惰嚜宸辩殑瀛楃闆嗙紪鐮佹潵灞曠ず鏌ヨ缁撴灉銆�
鎬荤粨锛� 聽file ------> server(engine) -----> client 聽闇�瑕佺粡杩囦笁娆$紪鐮侊紝涓ゆ缂栫爜杞寲銆�
鍙兘浼氭湁浜涚枒闂紝鍦ㄤ笂闈㈢殑鍒嗘瀽涓紝鏁版嵁閮芥槸浠ヤ簩杩涘埗娴佺殑鏂瑰紡鍦ㄥ悇涓妭鐐逛箣闂存祦鍔ㄧ殑銆傞偅涔堜负浠�涔堥渶瑕佺紪鐮佽浆鍖栦簡锛�
1銆乧lient 鍜� server(engine) 涔嬮棿鐨勮浆鎹紝鎴栬�呰缂栬В鐮佹槸涓轰簡瀵逛紶杩涙潵鐨勪簩杩涘埗娴佸仛璇硶鍜岃瘝娉曡В鏋愶紝鍚﹀垯浣犱笉浼氱煡閬撲紶杩涙潵鐨勬槸 insert 杩樻槸 update銆�
2銆乫ile 鍜� server(engine) 涔嬮棿鐨勮浆鎹㈡槸涓轰簡鍦ㄤ粠鏁版嵁鏂囦欢璇诲叆鏁版嵁鍚庯紝鍦ㄥ瓨鍌ㄥ紩鎿庡唴閮ㄨ繘琛屽瓧绗︾骇鍒殑鎿嶄綔銆�
3缁忚繃浠ヤ笂鍒嗘瀽锛屽簲璇ュ緢蹇彂鐜板鑷翠贡鐮佸嚭鐜扮殑鍘熷洜鏄湁浠ヤ笅鍑犵锛�
1銆佹暟鎹湪瀛樺叆鐨勬椂鍊欏拰鍙栧嚭鐨勬椂鍊欙紝缂栫爜涓嶄竴鑷淬�傛瘮濡傚瓨鍏ユ椂鐢ㄧ殑 utf8锛屽彇鍑烘椂鐢ㄧ殑 GBK銆�
2銆佺紪鐮佽浆鎹笉鏄棤鎹熺紪鐮佽浆鎹㈠鑷翠贡鐮佸嚭鐜般�傛瘮濡� clien 鏄� utf8锛宮ysql server 涓殑 character_set_client 璁剧疆涓� gbk锛岃〃缁撴瀯鐨勫瓧绗﹂泦璁剧疆涓� utf8銆傝繖閲屼細鏈変袱娆$紪鐮佽浆鍖栵紝client 鍒� server 鏃讹紝utf8 瑕佽浆涓� gbk锛岀劧鍚� server 鍒� file 鏃讹紝gbk 瑕佽浆涓� utf8銆傜敱浜� gbk 鍒� utf8 鏄湁鎹熺紪鐮佽浆鍖栵紝瀵艰嚧浜嗕贡鐮佸嚭鐜般��
鏃犳崯缂栫爜杞崲锛氬亣璁炬垜浠鎶婄敤缂栫爜 A 琛ㄧず鐨勫瓧绗� X锛岃浆鍖栦负缂栫爜 B 鐨勮〃绀哄舰寮忥紝鑰岀紪鐮� B 鐨勫瓧褰㈤泦涓苟娌℃湁 X 杩欎釜瀛楃锛岄偅涔堟鏃舵垜浠氨绉拌繖涓浆鎹㈡槸鏈夋崯鐨勩��
浣嗕笉鏄换浣曚袱绉嶅瓧绗﹂泦缂栫爜涔嬮棿鐨勮浆鎹㈤兘鏄湁鎹燂紝杞崲鏄惁鏈夋崯鍙栧喅浜庝互涓嬪嚑鐐癸細
------ 琚浆鎹㈢殑瀛楃鏄惁鍚屾椂鍦ㄤ袱涓瓧绗﹂泦涓�
------ 鏍囧瓧绗﹂泦鏄惁鑳藉瀵逛笉鏀寔瀛楃锛屼繚鐣欏叾鍘熸湁琛ㄨ揪褰㈠紡銆�(姣斿 latin1 鍦ㄩ亣鍒拌嚜宸辨棤娉曡〃绀虹殑瀛楃鏃讹紝浼氫繚鐣欏師瀛楃闆嗙殑缂栫爜鏁版嵁锛屽苟璺宠繃蹇界暐璇ュ瓧绗﹁繘鑰屽鐞嗗悗闈㈢殑鏁版嵁銆�)鍏嶈垂java浜ゆ祦缇わ細575057881
鍥犳鍙瀹㈡埛绔紝MySQL Server 鐨� character-set-client锛宼able charset 鐨勪笁涓瓧绗﹂泦瀹屽叏涓�鑷村氨鍙互淇濊瘉涓�瀹氫笉浼氭湁涔辩爜鍑虹幇浜嗐��
杞嚜锛歨ttps://mp.weixin.qq.com/s/F2ov8kiYlo8vzvlon3yevw