mongodb export import

     首先看看Mongodb的导出功能,在bin目录下有个mongoexport 用来实现导出功能,主要参数如下

 

写道
D:\mongodb_64-2.6.4\bin>mongoexport.exe --help
Export MongoDB data to CSV, TSV or JSON files.

Options:
--help produce help message
-v [ --verbose ] be more verbose (include multiple times
for more verbosity e.g. -vvvvv)
--quiet silence all non error diagnostic
messages
--version print the program's version and exit
-h [ --host ] arg mongo host to connect to ( <set
name>/s1,s2 for sets)
--port arg server port. Can also use --host
hostname:port
--ipv6 enable IPv6 support (disabled by
default)
-u [ --username ] arg username
-p [ --password ] arg password
--authenticationDatabase arg user source (defaults to dbname)
--authenticationMechanism arg (=MONGODB-CR)
authentication mechanism
--gssapiServiceName arg (=mongodb) Service name to use when authenticating
using GSSAPI/Kerberos
--gssapiHostName arg Remote host name to use for purpose of

   

写道
参数说明:

-h:指明数据库宿主机的IP

-u:指明数据库的用户名

-p:指明数据库的密码

-d:指明数据库的名字

-c:指明collection的名字

-f:指明要导出那些列

-o:指明到要导出的文件名

-q:指明导出数据的过滤条件

  例如:  

D:\mongodb_64-2.6.4\bin>mongoexport.exe -d test_his -c empilog -u test -p test -
o empilog.dat
connected to: 127.0.0.1
exported 600 records

 

DIR查看 写道
D:\mongodb_64-2.6.4\bin 的目录

2014/11/26 16:01 <DIR> .
2014/11/26 16:01 <DIR> ..
2014/08/08 21:30 18,788,864 bsondump.exe
2014/11/26 16:01 0 empilog.dat
2014/08/08 21:18 10,143,744 mongo.exe
2014/08/08 21:28 18,920,960 mongod.exe
2014/08/08 21:28 129,068,032 mongod.pdb
2014/08/08 21:29 18,846,720 mongodump.exe
2014/08/08 21:29 18,796,544 mongoexport.exe
2014/08/08 21:30 18,814,464 mongofiles.exe
2014/08/08 21:29 18,825,728 mongoimport.exe
2014/08/08 21:29 18,787,328 mongooplog.exe
2014/08/08 21:30 18,647,040 mongoperf.exe
2014/08/08 21:29 18,866,176 mongorestore.exe
2014/08/08 21:28 15,272,448 mongos.exe
2014/08/08 21:28 103,885,824 mongos.pdb
2014/08/08 21:29 18,836,992 mongostat.exe
2014/08/08 21:29 18,790,912 mongotop.exe

  接下来是导入mongoimport

   

写道
D:\mongodb_64-2.6.4\bin>mongoimport --help
Import CSV, TSV or JSON data into MongoDB.

When importing JSON documents, each document must be a separate line of the inp
t file.

Example:
mongoimport --host myhost --db my_cms --collection docs < mydocfile.json

Options:
--help produce help message
-v [ --verbose ] be more verbose (include multiple times
for more verbosity e.g. -vvvvv)
--quiet silence all non error diagnostic
messages
--version print the program's version and exit
-h [ --host ] arg mongo host to connect to ( <set
name>/s1,s2 for sets)
--port arg server port. Can also use --host
hostname:port
--ipv6 enable IPv6 support (disabled by
default)
-u [ --username ] arg username
-p [ --password ] arg password
--authenticationDatabase arg user source (defaults to dbname)

--jsonArray load a json array, not one item per
line. Currently limited to 16MB.

 

写道
参数说明:

-h:指明数据库宿主机的IP

-u:指明数据库的用户名

-p:指明数据库的密码

-d:指明数据库的名字

-c:指明collection的名字

-f:指明要导出那些列

-o:指明到要导出的文件名

-q:指明导出数据的过滤条件

  

写道

D:\mongodb_64-2.6.4\bin>mongoimport.exe -h 192.168.1.2 -port 10001 -d his -u his
-p his -c empilog empilog.dat
connected to: 192.168.1.2:10001
2014-11-27T10:38:51.278+0800 Progress: 84109/158467751 0%
2014-11-27T10:38:51.281+0800 100 33/second
2014-11-27T10:38:55.057+0800 Progress: 264890/158467751 0%
2014-11-27T10:38:55.058+0800 300 42/second
2014-11-27T10:38:59.524+0800 Progress: 462353/158467751 0%
2014-11-27T10:38:59.525+0800 500 45/second

 

 

 

你可能感兴趣的:(mongodb export import)