Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

Mongo shell startup configuration file .mongorc.js (2)

2025-02-25 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >

Share

Shulou(Shulou.com)06/01 Report--

Mongo shell startup configuration file .mongorc.js (2)

If you have a .mongorc.js file in your home directory, it will run automatically when you start shell. Use it to initialize any helper methods you use frequently and delete methods that you don't want to accidentally operate on.

For example, instead of using the default dropDatabase () method, you can add the following command to the .mongorc.js file:

DB.prototype.dropDatabase = function () {print ("No dropping DBs!");} db.dropDatabase = DB.prototype.dropDatabase

The above example changes the dropDatabase () helper method so that it prints only one line of information without actually deleting the database.

Note that this technique is not a security tool, and stubborn users can still delete databases without using helper. However, the command to remove dangerous admin permissions can also help prevent the "collapse of the levee".

Several suggestions for removal when using the helper command in .mongorc.js:

DB.prototype.shutdownServer

DBCollection.prototype.drop

DBCollection.prototype.ensureIndex

DBCollection.prototype.reIndex

DBCollection.prototype.dropIndexes

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Database

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report