{"data":{"question_details":{"data":{"answers":[{"qid":"6723591568617373966","aid":"6724551408470720781","uid":"92201346490","uname":"小小猿愛嘻嘻","avatar_url":"https://p9.toutiaoimg.com/img/mosaic-legacy/fe5e00001245e2b4e4f9~0x0.image","auth_info":"{\"auth_type\":\"0\",\"auth_info\":\"優質科技領域創作者\",\"other_auth\":{\"interest\":\"優質科技領域創作者\"}}","content":"\u003cp\u003eTXT文件數據導入MySQL數據庫,目前來說,有2種方式,一種是命令行導入,一種是借助客戶端軟件導入,下面我簡單介紹一下,感興趣的朋友可以操作一下,都非常容易:\u003c/p\u003e\u003cp\u003e為了更好的說明問題,這里假設導入的TXT文件數據如下,每行4列,每列之間使用Tab鍵進行分隔(也可以是其他分隔符,像逗號、分號等,影響不大):\u003c/p\u003e\u003cp\u003e\u003cimg src=\"https://p3.douyinpic.com/large/2b28500006cbb4032dcc5\" height=\"232\" width=\"460\" /\u003e\u003c/p\u003e\u003cp\u003e命令行導入\u003c/p\u003e\u003cp\u003e這種方式最基本也最簡單,需要先手動創建一個對應的數據表(和TXT文件數據格式保持一致),然后加載本地TXT文件(這里需要去掉TXT文件開始的標題行),最后再直接插入到數據表中,截圖如下,這里MySQL數據庫默認會按照Tab進行分割,如果是其他分隔符的話,可以使用fields terminated by關鍵字指定,逗號的話,是fields terminated by ',',分號是fields terminated by ';',非常容易:\u003c/p\u003e\u003cp\u003e\u003cimg src=\"https://p3.douyinpic.com/large/174f40007f256cc5325b4\" height=\"458\" width=\"630\" /\u003e\u003c/p\u003e\u003cp\u003e客戶端軟件導入\u003c/p\u003e\u003cp\u003e1.以Navicat MySQL客戶端軟件為例,雙擊打開對應數據庫,右鍵“表”,選擇“導入向導”,如下:\u003cbr/\u003e\u003c/p\u003e\u003cp\u003e\u003cimg src=\"https://p3.douyinpic.com/large/2b287000039331e3583d3\" height=\"282\" width=\"465\" /\u003e\u003c/p\u003e\u003cp\u003e2.接著在彈出的導入對話框中選擇“文本文件(.txt)”,點擊下一步,選擇需要導入的TXT文件,這時就可以指定列分隔符了,可以是分號、逗號、空格等,根據實際TXT文本格式選擇對應分隔符即可,如下:\u003c/p\u003e\u003cp\u003e\u003cimg src=\"https://p3.douyinpic.com/large/174f80007ee3629a95b42\" height=\"254\" width=\"519\" /\u003e\u003c/p\u003e\u003cp\u003e3.點擊下一步按鈕,進入附加選項,這里可以設置欄名(字段名)、數據、日期等,以上面測試數據為例,第1行是欄名,第2行開始才是真正數據:\u003c/p\u003e\u003cp\u003e\u003cimg src=\"https://p3.douyinpic.com/large/2b2910000680ea0e250f2\" height=\"294\" width=\"517\" /\u003e\u003c/p\u003e\u003cp\u003e4.最后再檢查一下導入的結構是否合理,這里可以對相應字段進行設置,包括調整類型、長度,設置主鍵等,一切配置完成后,直接點擊右下角開始按鈕即可導入:\u003c/p\u003e\u003cp\u003e\u003cimg src=\"https://p3.douyinpic.com/large/174f60007ef31d58b2505\" height=\"261\" width=\"520\" /\u003e\u003c/p\u003e\u003cp\u003e成功導入后的數據如下,和TXT文本數據一致:\u003c/p\u003e\u003cp\u003e\u003cimg src=\"https://p3.douyinpic.com/large/2b28600006c0493d288b3\" height=\"224\" width=\"468\" /\u003e\u003c/p\u003e\u003cp\u003e至此,我們就完成了將TXT文件數據導入到MySQL數據庫中。總的來說,整個過程非常簡單,第一種方式最簡單也最基本,先加載TXT文件,然后直接插入數據表即可,第二種方式借助客戶端軟件,手動導入,也非常容易,只要你熟悉一下上面的操作過程,很快就能掌握的,網上也有相關教程和資料,介紹的非常詳細,感興趣的話,可以搜一下,希望以上分享的內容能對你有所幫助吧,也歡迎大家評論、留言進行補充。\u003c/p\u003e","abstract":"TXT文件數據導入MySQL數據庫,目前...","create_time":1565681633,"update_time":1674205543,"digg_info":{"digg_count":0,"own_digg":false,"digg_list":null},"comment_info":{"comment_count":15},"repost_info":{"repost_count":14},"audit_info":{"audit_status":-1,"audit_status_msg":"","audit_status_msg_desc":""},"pv":0,"vl":69,"content_with_entity":"","extra":{"from_wukong":"1","group_decay_type":"9","modify_time":"1674205543","propedit_review_visibility":"{\"prop_name\":\"review_visibility\",\"prop_value\":\"69\",\"confidence\":11,\"editor\":\"content.online_cloud.flash_items\",\"reason_code\":0,\"reason_message\":null,\"edit_time\":null}","ugc_shark_decision":"{\"Decision\": \"PASS\", \"DecisionDetail\": \"\", \"HitStatus\": \"\"}","wd_source":"question_click_write_answer","wdh_client_ip":"124.115.236.17"},"integral_order_list":null,"integral_count":0,"bury_info":{"bury_count":0,"own_bury":false},"sent_flower_status":0,"could_show_flower_text":false,"author_digg_count":6,"author_show_digg_status":false,"ban_comment":false,"relation_info":{"is_following":false},"user_status":{"is_cancelled":false,"is_banned":false},"feedback_user_not_acted_aid":true,"help_info":{"is_helpful_count":0,"own_is_helpful":false}}],"has_more":false,"question":{"qid":"6723591568617373966","title":"如何把TXT文件數據導入MySQL數據庫?","content":"","pictures":null,"answer_count":1,"pv":834,"embrave":{"embrave_type":0,"integral_count":0,"gold_count":0,"reward_time":0},"create_time":1565458153,"vl":60,"audit_info":{"audit_status":2,"audit_status_msg":"","audit_status_msg_desc":""},"new_answer_cnt":0,"question_belong_status":2,"user_info":{"uid":"","uname":"lovetankai","avatar_url":"https://sf6-cdn-tos.toutiaostatic.com/img/mosaic-legacy/8611/3543154901~300x300.image"},"extra":{"from_wukong":"1","has_out_answer":"0","modify_time":"1674660744","wdh_client_ip":"127.0.0.1"},"img_q_integral":0,"feedback_user_not_answered":true,"feedback_user_not_acted":true},"rank1_could_show_flower_text":false,"contentType":"application/json; charset=utf-8","fontStyle":{"domains":["tosv.boe.byted.org"],"filename":"","base64":[],"fontKey":"","tosSuffix":""},"fontKey":"","fontStyleString":""},"errcode":0,"errmsg":"success"},"login_info":{"data":{"is_answered":1,"is_new":true,"uid":"","user_info":{"uid":"","uname":"","avatar_url":""}},"errcode":0,"errmsg":"success"}},"commonData":{"isSsrFrame":true,"ttLogId":"202302092112290101501341671EC018AB","location":{"hash":"","host":"so.toutiao.com","hostname":"so.toutiao.com","href":"https://so.toutiao.com/s/search_wenda_pc/list/?enter_from=search_result&qid=6723591568617373966&qname=如何把TXT文件數據導入MySQL數據庫?&search_id=202302092112280101501341671EC018A1&enter_answer_id=6724551408470720781&outer_show_aid=6724551408470720781&query=mysql怎么導入數據庫","origin":"https://so.toutiao.com","pathname":"/s/search_wenda_pc/list/","port":"","protocol":"https:","search":"?enter_from=search_result&qid=6723591568617373966&qname=如何把TXT文件數據導入MySQL數據庫?&search_id=202302092112280101501341671EC018A1&enter_answer_id=6724551408470720781&outer_show_aid=6724551408470720781&query=mysql怎么導入數據庫","username":"","password":""},"query":{"enter_from":"search_result","qid":"6723591568617373966","qname":"如何把TXT文件數據導入MySQL數據庫?","search_id":"202302092112280101501341671EC018A1","enter_answer_id":"6724551408470720781","outer_show_aid":"6724551408470720781","query":"mysql怎么導入數據庫"},"client":{"width":1920,"height":880,"pixelRatio":1,"userAgent":"Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/86.0.4240.198 Safari/537.36","isPC":true,"platform":"windows"},"serverEnv":"production","abFields":{},"user":{"webId":"7167564658018354696"},"isRPC":false,"params":{},"env":{"isBOE":false,"isProd":true,"isPPE":false,"cluster":"default"},"routingInfos":{"tc":"search_wenda_pc","business_path":"/list","routing_path":"/"}}}
網站導航
- zblogPHP模板zbpkf
- zblog免費模板zblogfree
- zblog模板學習zblogxuexi
- zblogPHP仿站zbpfang