Navicat Premium下sql匯入中文亂碼解決方案,navicatpremium

來源:互聯網
上載者:User

Navicat Premium下sql匯入中文亂碼解決方案,navicatpremium

        今天幫忙朋友找bug的時候,準備匯入她資料庫裡面的資料,所以我就試圖在mysql管理工具Navicat下面匯入相應的mysql命令。結果發現匯入的中文字元全部變成亂碼,所以做了如下這種嘗試:


      在“串連屬性”的設定中,進階-“使用mysql字元集”去掉鉤,並且將編碼改為10008-GB2312.
      然後進入navicat的控制台後,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       | D:\mysql-5.1.32-win32\share\charsets\ |
 
      此時我們需要在控制台運行 set names 'gbk'命令,運行後再次show variables like 'char%';命令查看結果如下:
 
      +--------------------------+---------------------------------------+
      | Variable_name            | Value                                 |
     +--------------------------+---------------------------------------+
      | character_set_client     | gbk                                   |
      | character_set_connection | gbk                                   |
      | character_set_database   | utf8                                  |
      | character_set_filesystem | binary                                |
      | character_set_results    | gbk                                   |
      | character_set_server     | utf8                                  |
      | character_set_system     | utf8                                  |
      | character_sets_dir       | D:\mysql-5.1.32-win32\share\charsets\ |
 
      用戶端串連環境設定算是完成了。接著中文資料該怎麼插還是怎麼插,不會再有亂碼出現。
 
      至於從.sql.txt等文本大量匯入資料,則需要將相應的檔案轉化為gbk格式儲存再匯入,否則匯入後會亂碼

      如果輸出的編碼格式不是以上格式,也可以通過下面的SQL語句來對其進行修改,MYSQL命令設定編碼格式:         set character_set_server = 'utf8';       轉載請註明出處:http://blog.csdn.net/pearyangyang/article/details/46127005



相關文章

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.