Hi, there.
I’m new to MongoDB and am running version 8.0 community edition.
In a Postgresql SQL context, dropping a DB (e.g. the foo DB) might use the following steps:
- Prevent any new connections: UPDATE pg_database SET datallowconn = ‘false’ WHERE datname = foo
- Drop any existing connections: SELECT pg_terminate_backend(pid) FROM pg_stat_activity WHERE datname = foo
- Drop the database: DROP DATABASE foo
If I’m looking at the MongoDB documentation correctly, it says that to drop a DB, you just need to run dropDatabase
:
Does MongoDB require any consideration for the 1st two steps? I know that I can accomplish step 1 with this:
db.runCommand({
revokeRolesFromUser: "username",
roles: [{ role: "readWrite", db: "foo" }]
});
But, my efforts to use killOp
, killAllSessions
for step 2 haven’t been successful. I did read a post on the MongoDB forums that illustrated that if the existing write operations/clients were not canned, then the database wouldn’t be dropped properly.
Thx for any help!
Rodney