您好,登錄后才能下訂單哦!
mysql 從文件導入sql 亂碼問題該怎么解決,相信很多沒有經驗的人對此束手無策,為此本文總結了問題出現的原因和解決方法,通過這篇文章希望你能解決這個問題。
首先我拿到sql文件沒亂碼,(用ultraedit 管理員界面可以看到文件編碼)
數據庫編碼和文件一致
下面就進到mysql里面看看variables
www.2cto.com
mysql> show variables like "%char%";
+--------------------------+---------------------------------------------------------------------------------+
| Variable_name | Value |
+--------------------------+---------------------------------------------------------------------------------+
| character_set_client | latin1 |
| character_set_connection | latin1 |
| character_set_database | utf8 |
| character_set_filesystem | binary |
| character_set_results | latin1 |
| character_set_server | utf8 |
| character_set_system | utf8 |
| character_sets_dir | /usr/local/Percona-Server-5.1.57-rel12.8-233--x86_64/share//charsets/ |
+--------------------------+---------------------------------------------------------------------------------+
8 rows in set (0.01 sec)
www.2cto.com
mysql> show variables like "%coll%";
+----------------------+-------------------+
| Variable_name | Value |
+----------------------+-------------------+
| collation_connection | latin1_swedish_ci |
| collation_database | utf8_bin |
| collation_server | utf8_bin |
+----------------------+-------------------+
3 rows in set (0.00 sec)
有幾個latin1的...
原來是connection的變量是latin1... 忍不了
修改sql文件
SET collation_connection = utf8_bin;
SET character_set_client = utf8;
SET character_set_connection = utf8;
mysql --socket=/opt/mydata/my3306/my3306.sock -A < xxx.sql 就好了...
看完上述內容,你們掌握mysql 從文件導入sql 亂碼問題該怎么解決的方法了嗎?如果還想學到更多技能或想了解更多相關內容,歡迎關注億速云行業資訊頻道,感謝各位的閱讀!
免責聲明:本站發布的內容(圖片、視頻和文字)以原創、轉載和分享為主,文章觀點不代表本網站立場,如果涉及侵權請聯系站長郵箱:is@yisu.com進行舉報,并提供相關證據,一經查實,將立刻刪除涉嫌侵權內容。