MongoDB ID Export, dump,sed,count,mysql import, etc. usage examples

Source: Internet
Author: User
Tags mysql import


#count Collection
Db.news.count ({"Lpublishtime": {"$gte": 1358697600000}});

#mongo导出
Mongoexport-h 192.168.1.175--port 33000-d booaa_so-c weibo-f ' _id '-Q ' {\ ' lweibotime\ ': {\ "\ $gte \": 1349020800000,\ "\ $l T\ ": 1351699200000}}"-O Weibo_20121201_33000.ids &


##################### #20121227. txt######################
#mongo导出0.1
Mongoexport--port 33000-d booaa_so-c bbs-f ' _id '-o 33000.bbs.ids;


#替换, replace the exported file contents with an INSERT SQL statement
#sed v1
Sed ' s/{' _id: {"\ $oid":/insert ignore into index_quene3_test (id,createtime) VALUES (/' 33001.bbs.ids> 33001.bbs. Ids_tmp
Sed ' s/}}/,now ()); 33001.bbs.ids_tmp> 33001.bbs.ids_final

#sed v2
Sed ' s/{' _id ": {" \ $oid ":"//' 20130121_33002_bbs.ids> 20130121_33002_bbs.ids_tmp
Sed ' s/'}}//' 20130121_33002_bbs.ids_tmp> 20130121_33002_bbs.ids_final

#sed 3
Sed ' s/insert into Index_quene/insert ignore into index_quene/' 33001.weibo.ids_final> 33001.weibo.ids_fffff


#mysql导入
#2013 -01-12 Import
Mysql-um4n-p01d060a476642ba8335b832ac5b211f222f641b5-h192.168.1.136-d boss_db < 33002.bbs.ids_final &
Mysql-um4n-p01d060a476642ba8335b832ac5b211f222f641b5-h192.168.1.136-d boss_db < 33002.blog.ids_final &


#统计文件行数数量
[Email protected] ~]$ wc-l weibo_20130121_33002.ids_final
4942900 weibo_20130121_33002.ids_final


#index_module MV
MV busstmp/weibomerge/weibo0/* buss/weibo0/
MV busstmp/weibomerge/weibo1/* buss/weibo1/


#mysql SQL Import
Insert Ignore to Index_quene4 (id,createtime) select Id,createtime from Index_quene4_test;

MongoDB ID Export, dump,sed,count,mysql import, etc. usage examples

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

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.