溫馨提示×

您好,登錄后才能下訂單哦!

密碼登錄×
登錄注冊(cè)×
其他方式登錄
點(diǎn)擊 登錄注冊(cè) 即表示同意《億速云用戶服務(wù)條款》

Mysql導(dǎo)出導(dǎo)入數(shù)據(jù)的方法介紹

發(fā)布時(shí)間:2021-09-18 14:42:51 來(lái)源:億速云 閱讀:129 作者:chen 欄目:MySQL數(shù)據(jù)庫(kù)

這篇文章主要介紹“Mysql導(dǎo)出導(dǎo)入數(shù)據(jù)的方法介紹”,在日常操作中,相信很多人在Mysql導(dǎo)出導(dǎo)入數(shù)據(jù)的方法介紹問題上存在疑惑,小編查閱了各式資料,整理出簡(jiǎn)單好用的操作方法,希望對(duì)大家解答”Mysql導(dǎo)出導(dǎo)入數(shù)據(jù)的方法介紹”的疑惑有所幫助!接下來(lái),請(qǐng)跟著小編一起來(lái)學(xué)習(xí)吧!

導(dǎo)出數(shù)據(jù)
**直接在系統(tǒng)執(zhí)行命令:
導(dǎo)出為cvs格式:

[root@slave ~]#  mysql  -u   root   -p密碼  -e  "select   *   from   mydb.name   into   outfile   '/tmp/12.cvs'    character  set  utf8"              --character set utf8 指定相應(yīng)編碼規(guī)則,不然可能亂碼

導(dǎo)出為txt格式:
[root@slave ~]#  mysql  -u  root  -p密碼  -e  "select * from mydb.name into outfile '/tmp/12.txt'  character set  utf8  lines  terminated  by '\r\n' "                            --導(dǎo)出為txt文件時(shí),不加lines  terminated  by '\r\n' (結(jié)尾符)在windows下會(huì)像一團(tuán)麻一樣.....

在mysql內(nèi):

導(dǎo)出為cvs格式:
mysql>selec t    *   from    mydb.name   into   outfile   '/tmp/12.cvs'   character   set   utf8;                - --character set utf8 指定相應(yīng)編碼規(guī)則,不然可能亂碼

導(dǎo)出為txt格式:
mysql> select    *   from    mydb.name    into     outfile  '/tmp/12.txt'  character   set  utf8  lines  terminated  by  '\r\n';                         --導(dǎo)出為txt文件時(shí),不加 lines  terminated  by '\r\n' (結(jié)尾符)在windows下會(huì)像一團(tuán)麻一樣.....

導(dǎo)出為cvs格式后,用WPS打開,相當(dāng)?shù)耐昝?

導(dǎo)入數(shù)據(jù)
mysql內(nèi)導(dǎo)入:
mysql>load   data    infile    '/tmp/12.txt'    into    table   name    character   set    uft8;     --character set utf8 指定相應(yīng)編碼規(guī)則,不然可能亂碼

直接在系統(tǒng)執(zhí)行命令:
[root@slave ~]# mysql  -u   root   -p密碼  -e  load   data    infile    '/tmp/12.txt'    into    table   name    character   set    uft8;        --character set utf8 指定相應(yīng)編碼規(guī)則,不然可能亂碼

遇到一個(gè)問題:emun類型的字段,導(dǎo)不入數(shù)據(jù)  ???

解決方法:
導(dǎo)入,導(dǎo)出時(shí)添加兩個(gè)參數(shù):  fields terminated by  和  optionally enclosed by

mysql>  select   *   from    name   into   outfile   '/tmp/11.txt'    character  set  utf8  fields    terminated     by '\、'     optionally    enclosed     by     '\"'   ;

mysql>  load   data   infile   '/tmp/11.txt'    into    table    nn    character   set    utf8    fields     terminated     by '\、' optionally     enclosed     by     '\"'   ;

到此,關(guān)于“Mysql導(dǎo)出導(dǎo)入數(shù)據(jù)的方法介紹”的學(xué)習(xí)就結(jié)束了,希望能夠解決大家的疑惑。理論與實(shí)踐的搭配能更好的幫助大家學(xué)習(xí),快去試試吧!若想繼續(xù)學(xué)習(xí)更多相關(guān)知識(shí),請(qǐng)繼續(xù)關(guān)注億速云網(wǎng)站,小編會(huì)繼續(xù)努力為大家?guī)?lái)更多實(shí)用的文章!

向AI問一下細(xì)節(jié)

免責(zé)聲明:本站發(fā)布的內(nèi)容(圖片、視頻和文字)以原創(chuàng)、轉(zhuǎn)載和分享為主,文章觀點(diǎn)不代表本網(wǎng)站立場(chǎng),如果涉及侵權(quán)請(qǐng)聯(lián)系站長(zhǎng)郵箱:is@yisu.com進(jìn)行舉報(bào),并提供相關(guān)證據(jù),一經(jīng)查實(shí),將立刻刪除涉嫌侵權(quán)內(nèi)容。

AI