Mongodb 使用方法 导入数据 导出数据

Mongodb 使用方法

mongo 进入mongodb

Show dbs 查看所有数据库

db  查看当前数据库

use test 使用test数据库

show collections 查看所有表

db.help();  

db.user.help();  user为表名

db.foo.find() #查找所有查询数据使用db.表名.find()查询数据

db.foo.findOne()  #查找一条记录

 

MongoDB数据库备份

linux

sudo mongodump -h 192.168.17.129:27017 -d Province_spider -o /home/mongodump/

windows

mongodump -h localhost:27017 -d Province_spider -o F:/mongodbdata

 

 

MongoDB数据库恢复

Linux

mongorestore -h 192.168.17.129:27017 -d bak_Province_spider --dir /home/mongodump/itcast/

Windows

mongorestore -h localhost:27017 -d bak_Province_spider --dir F:\mongodbdata\Province_spider

 

猜你喜欢

转载自blog.csdn.net/xcyww/article/details/89187743