0
votes

I'm beginning to use MongoDB and have spent several hours troubleshooting without resolve. From what I understand, there first needs to be a root user before there can be an authorized/admin user.

I installed in C:\mongodb\, then setup --dbpath in C:\mongodb\data and --logpath in C:\mongodb\logs\log.txt.

I installed then ran the MongoDB service, accessible in the services.msc

My recipe to disaster was:
1. mongo localhost,
2. use admin
3. db.createUser({ user: 'root', pwd: '123456', roles:['root']})

Then get "Error: couldn't add user: not authorized on admin to execute command { createUser ....."

I am running MongoDB shell version: 2.6.5 and greatly appreciate any help that leads to a solution.

Thank you,
Leo

1
Now, that is strange. Restart mongo with authentication disabled and retry, please. Then, restart it using auth enabled and login with mongo admin -u root -p and try to add other users. Btw, it makes sense to have a dedicated user admin user.Markus W Mahlberg
I figured it out. I accidentally put the data and logs in same drive/folder, I guess it spat errors because of it. I put the new data/logs in the D drive, and now it works. (9 hours of troubleshooting to come to this point :)leocreatini

1 Answers

0
votes

I figured it out. I accidentally put the data and logs in same directory as the \mongodb\bin. The solution is to put the mongodb\data and mongodb\logs in a separate folder or drive -- I differentiated using C:\~ and D:\~ drives.