Mysql匯出/匯入資料

來源:互聯網
上載者:User

標籤:mysql 匯入匯出

匯出資料
**直接在系統執行命令:
匯出為cvs格式:

[[email protected] ~]# mysql -u root -p密碼 -e "select * from mydb.name into outfile ‘/tmp/12.cvs‘ character set utf8" --character set utf8 指定相應編碼規則,不然可能亂碼

匯出為txt格式:
[[email protected] ~]# mysql -u root -p密碼 -e "select * from mydb.name into outfile ‘/tmp/12.txt‘ character set utf8 lines terminated by ‘\r\n‘ " --匯出為txt檔案時,不加lines terminated by ‘\r\n‘ (結尾符)在windows下會像一團麻一樣.....

在mysql內:

匯出為cvs格式:
mysql>selec t * from mydb.name into outfile ‘/tmp/12.cvs‘ character set utf8; - --character set utf8 指定相應編碼規則,不然可能亂碼

匯出為txt格式:
mysql> select * from mydb.name into outfile ‘/tmp/12.txt‘ character set utf8 lines terminated by ‘\r\n‘; --匯出為txt檔案時,不加 lines terminated by ‘\r\n‘ (結尾符)在windows下會像一團麻一樣.....

匯出為cvs格式後,用WPS開啟,相當的完美!

匯入資料
mysql內匯入:
mysql>load data infile ‘/tmp/12.txt‘ into table name character set uft8; --character set utf8 指定相應編碼規則,不然可能亂碼

直接在系統執行命令:
[[email protected] ~]# mysql -u root -p密碼 -e load data infile ‘/tmp/12.txt‘ into table name character set uft8; --character set utf8 指定相應編碼規則,不然可能亂碼

遇到一個問題:emun類型的欄位,導不入資料 ???

Mysql匯出/匯入資料

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

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.