MongoDB remote connection via RoboMongo

I am trying to connect to my Mongodb server through Robomongo.

I changed Bind_ip to 0.0.0.0 on the mongod.conf server mongod.conf I also set the auth=true field.

Now when I try to login from RoboMongo, I get an error with auth error.

Honestly, I have no idea what a username or password is (I did not set any users after installing Mongo, and I do not want to do this because I use nodeJs to query db and when I try to log in I also get out [thats with mongoskin])

Does Mongodb have a default username or password? or what else can i do?

+6
source share
2 answers

Does Mongodb have a default username or password?

There are no default users created by MongoDB, however if you have just enabled authentication and have not created your first user yet (which should be the userโ€™s administrator), then you need to connect via localhost to configure the initial user. There is a localhost exception enabled by default to specifically allow the creation of the first user with auth enabled. Remote connections cannot authenticate without valid user credentials.

After you create the user (s) you need, you must log in remotely with these credentials using Robomongo or another interface, such as the mongo shell or your mongoskin application.

If you do not want to use the localhost exception, an alternative approach is to start your MongoDB server with auth disabled, add remote users, and then restart the server with authorization enabled.

+4
source

All you need is in the docs: http://docs.mongodb.org/manual/tutorial/enable-authentication/

Create admin user (role):

 use admin db.createUser( { user: "siteUserAdmin", pwd: "password", roles: [ { role: "userAdminAnyDatabase", db: "admin" } ] } ) 

Add regular users (read record):

 use reporting db.createUser( { user: "reportsUser", pwd: "12345678", roles: [ { role: "read", db: "reporting" }, { role: "read", db: "products" }, { role: "read", db: "sales" }, { role: "readWrite", db: "accounts" } ] } ) 

To add an administrator, you probably need to start mongo with auth=false , add an administrator, and enable auth=true again.

View Roles : db.getRoles()

+2
source

Source: https://habr.com/ru/post/980610/


All Articles