当前位置:网站首页>Mongodb cross host database copy and common commands
Mongodb cross host database copy and common commands
2022-06-27 09:59:00 【Hilbob】
One 、 Tool preparation
Copy mongodb The database inside needs tools mongodump and mongorestore. download mongodb You did not download the above tools , You can download and decompress it directly from here : MongoDB Database Tools
Two 、 Data copy
Go to the path extracted by the above tool , Use the following command to copy the specified database :
mongodump -h dbhost -d dbname -o dbdirectory
# explain
-h:
MongoDB Address of the server , for example :127.0.0.1, Of course, you can also specify the port number :127.0.0.1:27017
-d:
Database instances that need to be backed up , for example :test
-o:
Backup data storage location , for example :c:\data\dump, Of course, the directory needs to be established in advance , After the backup is complete , The system is automatically in dump Create one in the directory test Catalog , This directory contains the backup data of the database instance .
3、 ... and 、 Data transfer and recovery
Use the above mongodump The file generated by the command is copied to another host
Execute on another host :
mongorestore -h <hostname><:port> -d dbname <path>
# explain
--host <:port>, -h <:port>:
MongoDB Address of the server , The default is : localhost:27017
--db , -d :
The name of the database instance to be recovered . for example :test, Of course, this name can also be different from the backup time , such as test2
--drop:
When you recover , Delete the current data first , Then restore the backup data . That is to say , After recovery , The data added and modified after backup will be deleted , Use with caution !
<path>:
mongorestore The last parameter , Set the location of backup data , That is, the path where the data replication is located , for example :c:\data\dump\test.
You can't specify at the same time <path> and --dir Options ,--dir You can also set the backup directory .
--dir:
Specify the directory to back up
You can't specify at the same time <path> and --dir Options .
This will be done on another host mongodb Restore the copied database .
Four 、mongodb Common commands
Activate mongodb Environmental Science
> mongod
Use after activating the environment mongodb
> mongo
See which databases are currently available
> show dbs
Check which database is currently connected to , You can input db
> db
Switch to test Under database
> use test
You want to view the tables under the current database collection
> show collections
Reference resources
边栏推荐
- R language plot visualization: visualize the normalized histograms of multiple data sets, add density curve KDE to the histograms, set different histograms to use different bin sizes, and add edge whi
- Prometheus alarm process and related time parameter description
- 你睡觉时大脑真在自动学习!首个人体实验证据来了:加速1-4倍重放,深度睡眠阶段效果最好...
- vector::data() 指针使用细节
- Reading and writing Apache poi
- Quick start CherryPy (1)
- R language uses econcharts package to create microeconomic or macro-economic charts, demand function to visualize demand curve, and customize the parameters of demand function to enrich the visualizat
- js中的数组对象
- R语言使用econocharts包创建微观经济或宏观经济图、demand函数可视化需求曲线(demand curve)、自定义配置demand函数的参数丰富可视化效果
- On anchors in object detection
猜你喜欢
为智能设备提供更强安全保护 科学家研发两种新方法
通俗易懂理解樸素貝葉斯分類的拉普拉斯平滑
Principle and application of the most complete H-bridge motor drive module L298N
测试同学怎么参与codereview
细说物体检测中的Anchors
This application failed to start because it could not find or load the QT platform plugin
How do I get the STW (pause) time of a GC (garbage collector)?
[200 opencv routines] 211 Draw vertical rectangle
Product strength benchmarking seal /model 3, with 179800 pre-sales of Chang'an dark blue sl03
Oracle连接MySQL报错IM002
随机推荐
Freemarker
C# Any()和AII()方法
R語言plotly可視化:可視化多個數據集歸一化直方圖(historgram)並在直方圖中添加密度曲線kde、設置不同的直方圖使用不同的分箱大小(bin size)、在直方圖的底部邊緣添加邊緣軸須圖
R语言plotly可视化:plotly可视化基础小提琴图(basic violin plot in R with plotly)
oracle触发器 存储过程同时写入
强化学习中好奇心机制
Product strength benchmarking seal /model 3, with 179800 pre-sales of Chang'an dark blue sl03
基于STM32设计的蓝牙健康管理设备
torch.utils.data.RandomSampler和torch.utils.data.SequentialSampler的区别
[so official interview] Why do developers using rust love it so much
导师邀请你继续跟他读博,你会不会立马答应?
如何获取GC(垃圾回收器)的STW(暂停)时间?
谷歌浏览器 chropath插件
Only one confirmcallback is supported by each rabbittemplate
JS 文件上传下载
R语言使用econocharts包创建微观经济或宏观经济图、demand函数可视化需求曲线(demand curve)、自定义配置demand函数的参数丰富可视化效果
技术与业务同等重要,偏向任何一方都是错误
Quick start CherryPy (1)
Comparison between new and old interfaces
细说物体检测中的Anchors