I am trying to rename a database from within pymongo. I understand that the way to do this is to copy the database, then delete the original (right?), thus I am trying to run the code:
The user that successfully logged in has the Built-In role Atlas Admin. However, running this code gives me an error:
OperationFailure: (Unauthorized) not authorized on admin to execute command
How is this possible, doesn’t the Atlas Admin have all the rights to do anything?
The copydb admin command was deprecated in MongoDB 4.0 and removed in MongoDB 4.2. The removal notice includes an alternative approach using mongodump and mongorestore (which has --nsFrom and --nsTo options to rename a namespace).
The copydb command (and associated shell helpers) had a number of unfortunate caveats including limited auth support, not taking a point-in-time snapshot, no support for sharding, and foreground index builds (which will take a lock on the target database).
The PyMongo example you found is unfortunately no longer relevant for modern versions of MongoDB server and should be removed (PYTHON-3138).
Atlas does not support commands that are taken care of by the management interface or not applicable to shared clusters. For more details, please see: