Unable to shutdown database

So, for one of the labs, we were supposed to modify the config file to read the database files from a different location. I updated the config file w/o shutting down the database so when I tried to shut it down I was getting:
"errmsg" : "not authorized on admin to execute command { shutdown: 1.0, $db: \"admin\" }",

Quick solution, logout, halt vagrant and start the database again w/the new config file. In a production environment, what should I do? It’s safe to mention that I did tried to revert the changes in the config file but that didn’t make any difference.

Thanks!

In the mongo shell you can try:
db.auth(“m103-admin”,“m103-pass”)

And after that, you will be able to shutdown the server:
use admin
db.shutdownServer()
quit()

2 Likes

Hi,

I get the below error

MongoDB Enterprise > db.auth(“m103-admin”,“m103-pass”)
Error: Authentication failed.
0

Thanks

Hi MAHENDIRAN_93703,

You have to first be in the database where you have created m103-admin user.

use admin
db.auth("m103-admin","m103-pass")

If it still fails, please re-check or re-create the user.

Kanika

1 Like

@MAHENDIRAN_93703 The other alternative to the solution @Kanika mentioned is passing the credentials to mongoshell when you are connecting.

To your other question, in a production environment modifying any configuration would likely occur during a scheduled maintenance window, especially if you are modifying the underlying storage location of the database itself (i.e pointing mongo to a different database path?). Although depending on the particular case, different instances could be brought offline by specifying a new primary, and the secondaries could be modified. All of this is heavily dependent on policies and procedures of the a specific organization, etc…

In general though, modifications like that won’t get reflected as the database would read the configuration only upon initial startup. Then using tools like MongoShell to carefully administer the instance at runtime.

HTH,
Mike

2 Likes