[SERVER-1061] Make renameCollection command not admin-only Created: 28/Apr/10  Updated: 12/Jul/16  Resolved: 25/May/11

Status: Closed
Project: Core Server
Component/s: Usability
Affects Version/s: None
Fix Version/s: 1.9.1

Type: Improvement Priority: Major - P3
Reporter: Mathias Stearn Assignee: Mathias Stearn
Resolution: Done Votes: 1
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Participants:

 Comments   
Comment by Robert Kennington [ 21/Aug/12 ]

To clarify for the novice user as it took a while for me to digest what this FIX means, a non-admin user can rename a collection if it is not sharded. And, this ONLY applies to sharded and unsharded databases that have been administratively locked. However, unlike the user friendly

db.<collection name>.drop()

command, this requires execution of an administrative command as follows:

> use <database name>

> db.auth('<username>','<password>')
1
> db.runCommand(

{renameCollection: "<database name>.<old collection name>", to: "<database name>.<new collection name>"}

)

{ "ok" : 1 }

>

See http://docs.mongodb.org/manual/reference/commands/#renameCollection for further details.

Note: the renameCollection command

db.<old collection name>.renameCollection('<new collection name>')

still only works for admin users in a locked database. So, you must switch (i.e. use admin) and authenticate as an administrative user to use this command.

Comment by auto [ 25/May/11 ]

Author:

{u'login': u'RedBeard0531', u'name': u'Mathias Stearn', u'email': u'mathias@10gen.com'}

Message: renameCollection should only require auth on source and dest DBs, not admin SERVER-1061

Still technically an admin command and requires running against admin db
Branch: master
https://github.com/mongodb/mongo/commit/52d7736f73c78e70697c8b239eea4ecc24b9541b

Comment by Eliot Horowitz (Inactive) [ 13/May/11 ]

We should make the api the same, just make it smart about authentication.

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