[SERVER-20793] How Can I drop old system.users collection? Created: 07/Oct/15  Updated: 31/Dec/23  Resolved: 07/Oct/15

Status: Closed
Project: Core Server
Component/s: Admin
Affects Version/s: 2.6.10
Fix Version/s: None

Type: Question Priority: Major - P3
Reporter: Filip Havlí?ek Assignee: Unassigned
Resolution: Done Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Participants:

 Description   

How Can I drop system.users collection in database? In previsus versions of MongoDB every database has its own system.users collection but in newer (I think since 2.6) are credentials stored in admin.system.users. I try to drop obsolete collection (somedatabase.system.users), but I can't.
I tried it with user with these roles: readWriteAnyDatabase, userAdminAnyDatabase, dbAdminAnyDatabase, clusterAdmin (all on admin database) .
Error message:
{{
rs:PRIMARY> db.system.users.drop()
2015-09-21T13:55:09.502+0200 drop failed: {
"ok" : 0,
"errmsg" : "not authorized on somedatabase to execute command

{ drop: \"system.users\" }

",
"code" : 13
} at src/mongo/shell/collection.js:598
}}



 Comments   
Comment by Ramon Fernandez Marina [ 12/Oct/15 ]

filip.havlicek@livesport.eu, the reason these collections are not removed as part of the upgrade and no instructions to remove them are provided is to allow users to revert to 2.4 if they need to.

After upgrading to 2.6 these collections are not used for anything, so it's safe to remove them as you described above. To drop them directly you may need to add drop privileges explicitly, but I haven't tested that approach.

Comment by Filip Havlí?ek [ 07/Oct/15 ]

Yes, it's true, but nobody knows or nobody want to help..
Isn't possible move ticket to different project? Because this theme isn't in documentation and I hope that's not only me, who is interested about it. I think this should be a part of documentation of upgrade process from 2.4 to 2.6.

Comment by Ramon Fernandez Marina [ 07/Oct/15 ]

I see that you've already posted your question in the mongodb-user group, and since we keep the SERVER project for
reporting bugs or feature suggestions for the MongoDB server we're closing this ticket.

See also our Technical Support page for additional support resources.

Regards,
Ramón.

Comment by Filip Havlí?ek [ 07/Oct/15 ]

OK.. I find a way which works.
At first I need a user with "restore" role (my user has "root" and "restore" role).
Then I can rename system.users with command db.system.users.renameCollection("oldusers") and oldusers collection is possible to drop.
The same way I drop system.backup_users and system.new_users in admin database.

Is this a safe way how to drop old $database.system.users, admin.system.backup_users, admin.system.new_users collections? Is it safe for replica sets and sharding clusters too?

Generated at Thu Feb 08 03:55:18 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.