当前位置:网站首页>Introduction of mongod management database method
Introduction of mongod management database method
2022-07-07 15:19:00 【1024 questions】
Today, I mainly understand database management , Before operation MongoDB Service open .
If you want to view the database list, you can use show dbs
.
By using MongoDB Built in handle in db To perform database operations . When operating on different databases , have access to db.getSiblings(database) Method or use <database>.
db=db.getSiblingDB('testDB')use testDB
Both of the above methods switch the current database handle to testDB, And put db Set the value of to the specified database .
3、 ... and 、 Create databaseMongoDB Not provided shell The command to create the database shown in . have access to <new_database_name> Create a new database handle , But unless you add the collection to a new database , Otherwise it will not actually be saved . In the following screenshot, create a new database handle and execute show dbs The original database is still displayed . After adding the collection, there will be a new database .
If there is a creation display, there will definitely be a deletion , Deleting a database is also very simple and practical dropDatabase() Method . above show dbs You can see that there are three databases , Use dropDatabase() Then let's see how many .
You can see that after deleting one, there are still 2 A database ,3-1=2 Well
Copying a database will create a database that is exactly the same except for its name , It is generally used for backup or archiving .
Create a copy of the database , You can switch to this database , And then use copyDatabase(origin,destination,[hostname]) To create a copy .origin The argument is a string , Specify the name of the database to be copied ,destination Parameters are specified here MongoDB The name of the database to be created on the server . Optional hostname Parameter assignment origin database MongoDB The hostname of the server ( If you copy databases from different hosts ). The screenshot below is to create a new newDB database , It adds a set and Person, Then create a by copying the database testDB database .show collections You can see that it also exists Person aggregate .
This is about MongoDB This is the end of the article on database management . I hope it will be helpful for your study , I also hope you can support the software development network .
边栏推荐
- Unity之ASE实现卡通火焰
- MySQL bit type resolution
- 一个需求温习到的所有知识,h5的表单被键盘遮挡,事件代理,事件委托
- Ctfshow, information collection: web7
- Ctfshow, information collection: web1
- 【目标检测】YOLOv5跑通VOC2007数据集
- Protection strategy of server area based on Firewall
- Typescript release 4.8 beta
- Promoted to P8 successfully in the first half of the year, and bought a villa!
- [make a boat diary] [shapr3d STL format to gcode]
猜你喜欢
How to enable radius two factor / two factor (2fa) identity authentication for Anheng fortress machine
拜拜了,大厂!今天我就要去厂里
[server data recovery] a case of RAID data recovery of a brand StorageWorks server
Niuke real problem programming - day18
[Data Mining] Visual Pattern Mining: Hog Feature + cosinus Similarity / K - means Clustering
银行需要搭建智能客服模块的中台能力,驱动全场景智能客服务升级
【OBS】RTMPSockBuf_Fill, remote host closed connection.
CTFshow,信息搜集:web14
IDA pro逆向工具寻找socket server的IP和port
【数据挖掘】视觉模式挖掘:Hog特征+余弦相似度/k-means聚类
随机推荐
Cocoscreator operates spine for animation fusion
Ctfshow, information collection: web5
Deformable convolutional dense network for enhancing compressed video quality
Novel Slot Detection: A Benchmark for Discovering Unknown Slot Types in the Dialogue System
连接ftp服务器教程
CTFshow,信息搜集:web5
Apache多个组件漏洞公开(CVE-2022-32533/CVE-2022-33980/CVE-2021-37839)
CTFshow,信息搜集:web8
Nacos一致性协议 CP/AP/JRaft/Distro协议
Typescript release 4.8 beta
MySQL bit类型解析
Unity's ASE realizes cartoon flame
全日制研究生和非全日制研究生的区别!
CTFshow,信息搜集:web3
Niuke real problem programming - Day12
IDA pro逆向工具寻找socket server的IP和port
TypeScript 发布 4.8 beta 版本
Classification of regression tests
微信小程序 01
Window环境下配置Mongodb数据库