In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-16 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >
Share
Shulou(Shulou.com)05/31 Report--
Today, I will talk to you about how to import Mysql data into MongoDB. Many people may not know much about it. In order to make you understand better, the editor has summarized the following content for you. I hope you can get something according to this article.
(1) Export data bit csv files from mysql, such as:
Java code
SELECT * FROM APP_CALL_LOG_1362959187037 WHERE CREATE_TIME
< '2013-03-07 14:45:04' into outfile '/tmp/all_call_log_012.csv' fields terminated by ',' lines terminated by '\n'; (2)导入csv文件到mongodb,如: Java代码 bin/mongoimport --host 114.112.94.104 --port 27017 -d lb_v1_log -c APP_CALL_LOG --type csv --ignoreBlanks -f ID,IP,URI,URL,D_CODE,D_TYPE,UID,APP_FROM,CREATE _TIME,USER_AGENT,REMARK -file /usr/local/all_call_log_012.csv (3)对导入数据矫正处理,如: Java代码 pmy_log_rs:PRIMARY>Db.APP_CALL_LOG.update ({UID: "\ N"}, {$set: {'UID': null}}, false,true)
Pmy_log_rs:PRIMARY > db.APP_CALL_LOG.update ({IP: "\ N"}, {$set: {'IP': null}}, false,true)
Pmy_log_rs:PRIMARY > db.APP_CALL_LOG.update ({D_TYPE: "\ N"}, {$set: {'Down typewriter: null}}, false,true)
Pmy_log_rs:PRIMARY > db.APP_CALL_LOG.update ({D_CODE: "\ N"}, {$set: {'Down codes: null}}, false,true)
Pmy_log_rs:PRIMARY > db.APP_CALL_LOG.update ({CREATE_TIME: "\ N"}, {$set: {'CREATE_TIME': null}}, false,true)
Pmy_log_rs:PRIMARY > db.APP_CALL_LOG.update ({APP_FROM: "\ N"}, {$set: {'APP_FROM': null}}, false,true)
Pmy_log_rs:PRIMARY > db.APP_CALL_LOG.update ({URI: "\ N"}, {$set: {'URI': null}}, false,true)
Pmy_log_rs:PRIMARY > db.APP_CALL_LOG.update ({URL: "\ N"}, {$set: {'URL': null}}, false,true)
Pmy_log_rs:PRIMARY > db.APP_CALL_LOG.update ({USER_AGENT: "\ N"}, {$set: {'USER_AGENT': null}}, false,true)
Pmy_log_rs:PRIMARY > db.APP_CALL_LOG.update ({REMARK: "\ N"}, {$set: {'REMARK': null}}, false,true)
(4) Field type correction, such as:
Java code
Db.APP_CALL_LOG.find ({}) .forEach (function (x) {x.D_CODE = "" + x.During CODEX db.App) CALLLCODEX LOG.save (x)
After reading the above, do you have any further understanding of how to import Mysql data into MongoDB? If you want to know more knowledge or related content, please follow the industry information channel, thank you for your support.
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.