1

Using mongo tools only.....

Is there a way to delete a remote Mongo Atlas Database using the mongoDB Command Line DB tools, is it doable using MongoDB Atlas API (via curl), or is it only doable using the Mongo Shell ?? The system I am working on already has the command line tools, and I'm trying not add new software on to the machine.

Need this for CI/CD testing purposes.

Walter Kelt
  • 2,199
  • 1
  • 18
  • 22
  • Dropping a database via APi was discussed here: https://www.mongodb.com/community/forums/t/how-to-drop-a-database-with-mongodb-atlas-api/116764 – Joe Jan 10 '22 at 21:12

1 Answers1

0

You can use the db.runCommand( { dropDatabase: 1 } ) and its wrapper db.dropDatabase() from the command line mongo shell to drop a database and its associated files. Note that the database delete operation removes all the collections in it.

For example, from the mongo shell delete the "mydb" database:

use mydb
db.dropDatabase()

// -or- from any current database:

db.getSiblingDB("mydb").dropDatabase()

The following are the aspects which are concerned with this command: write concern, locks, user management, indexes and the clusters (replica sets and sharded); refer the following links for details: dropDatabase command and db.dropDatabase().

You can also drop a database from the MongoDB Compass GUI tool.

You can also execute the drop database command from any of the MongoDB programming language driver APIs.

prasad_
  • 12,755
  • 2
  • 24
  • 36