mongodb 用命令导入导出数据库,用命令在Robo3T 上查询。
mongodb导入导出命令
快捷方式:如果没有配置mongodb的环境变量,可直接在mongodb的安装bin目录下,将相应的json文件复制到这里,去除json后缀名执行命令。
需要配置环境变量的可自行百度。
数据库名:test 密码:123456
导入的数据表名:table1
导进去的数据表名: table2
当前ip地址和端口号:localhost:27017
导入命令
mongoimport -h localhost:27017 -u test -p 123456 -d test -c table1 table2
导出命令
mongoexport -h localhost:27017 -u test -p 123456 -d test -c table2 -o table2.json
最后导出的结果为table2.json
在Robo3T上查询
右键数据库,选择Open Shell,右侧栏中会出现黑色框,在框里输入要进行的查询命令,比如我要进行查询_id = d888e8b4ac6e4407a5c57409f82fbbb0的记录。则输入命令:
db.test.find({"_id":“d888e8b4ac6e4407a5c57409f82fbbb0”}),然后点击如下图所示步骤。