Being new to the MongoDB database, only in my second week of training, I wanted to test the MongoVUE gui tool to see if it would help make my administration easier.
On a local virtual machine, I have a copy of MongoDB running on Ubuntu. Up until this point, I have been doing everything in the Mongo shell.
After installing an evaluation version of MongoVUE, I attempted to have it connect to the my Mongo database called “pcat”. “Pcat” is the database that I am using in my training class. I appeared to receive a successful connection to the database using my OS logon & password. However, when I clicked to view the Collections, I received the message: “Invalid credentials for database ‘pcat’.
In this case, I had two issues with to resolves before I could connect and administer the ‘pcat’ database:
1. Configure the MongoDB software to authenticate for remote connections.
2. Create a user that I can authenticate in the ‘pcat’ database.
The first step is to alter the configuration file that the process ‘mongod’ is using. On the server, by running ‘ps -ef | grep mongod’, I was able to see that the process was using the configuration file ‘mongodb.conf’ that resided in the ‘/etc’ directory. The configuration file may reside in a different location based on your operating system & configuration at setup.
Using an editor on that file (like vi), I was able to see that the authentication parameter for remote users was remarked out. I removed the pound sign in front of the “auth = true”, and saved the file. Then I restarted the Mongod process by typing “sudo service mongodb restart”. Now remote users are able to authenticate to the database.
Second, we need a user that is permitted to access the database remotely. In the Mongo shell I had to switch to the ‘pcat’ database, by typing “use pcat”. Then I added a user with the command db.addUser, like db.addUser(” <username> ” , ” <password> “). In my example, I used “buddy” for both the name & password. I then verified the user with the “show users” command.
After creating the user, I was able to go back to my MongoVUE application, and enter the connection information in the “MongoVUE Connection”, with an example pictured below.
Then I was able to successfully connect to the MongoDB database, and view the Collections.
If this does not resolved the error, then check the “mongodb.log” on the database server, which is normally located in the “/var/log/mongodb” directory.