Mongodbd login with Mongoose to new database - mongodb

I use mongoDB in Atlas cloud but now I want to movie to a local database. I installed MongoDB and created a admin user. Now I connect with mongoose to :
mongodb://login:pass#db.myserver.com:27017/admin
Works well. Now I create a new development database "develop".
I try to connect
mongodb://login:pass#db.myserver.com:27017/develop
This failed to login. OK, I understand that the admin database is the "/admin" one and that user is authenticated to this database but I thought that an admin can access all databases in a mongodb server?
In Atlas I just created the develop database and connected to it without any problem.
How I can well connect with mongoose to the new develop database? Do I need to create a second admin for this database?

Ok, I found out that I have to name the auth database in my connection string.
mongodb://login:pass#db.myserver.com:27017/develop?authSource=admin

Related

Mongo db is not connecting

I have drupal8 application where I use various dbs. When i try to connect with mongo db by giving username and password, connection is not happening. I could connect with mongo db by mentioning server address alone.
note: mongodb is configured with username and password in my server
I tried below methods.
$this->connect_string = 'mongodb://user:password#serveraddress'; (not connecting)
$this->connect_string = 'mongodb://serveraddress'; (connecting)
#$this->connect_string = 'mongodb://user:password#serveraddress:27017/?authSource=dbname';(not connecting)
Php v-7.4, Drupal 8
developed custom module to connect with mongo db, to display news feed (news feed related information stored in mongo db).
how to pass user name & password to connect with mongo db?
Could not find any error logs in mongodb server.

Azure DocumentDB and Meteor Accounts

My Meteor app is connected to a DocumentDB database, I try to create a Meteor Accounts using Accounts.createUser({}) , but I can't login to the user because I have been logged out automatically. and the resume.TokenLogin are not removed from the database.
I try to compare that behavior with the local MongoDB one, I found that in local MongoDB some collections are created: users,
meteor_accounts_loginServiceConfiguration and system.indexes but in the docuementDB just users and meteor_accounts_loginServiceConfiguration are created.
I don't khnow if the problem is related with the collection system.indexes or if I need to add somethings to not been logged out automatically after each authentification !

how to add a mlab database to mongodb

I installed mongodb and connected to it using my terminal. Everything is fine, but the db is the test one. I created an account in mlab to add a new database, but I don't understand how to do so. I have already created a db user.

not able to connect to mongodb because of unauthorized lock type

I am trying to connect to my mongodb deployed in jelastic cloud
If i try to use the test database already provided in the mongodb node in jelastic..it works fine.But if i create my own database and try to access the collections created in it ..i get the following exception
com.mongodb.MongoException: unauthorized db:appdb lock type:-1 client:192.168.1.53
Why is this happening?how can i resolve it?
I am reading the configuration from a file mydb.cfg
host=mongodb-***.jelastic.servint.net
dbname=appdb
user=admin
password=*****
When in Rock Mongo web interface pick the targeted db and go for 'More' in config panel.
This has to show you the list of users having rights for DB.
Did you set the user and rights for your custom collection?
Try to check the configuration under 'Authentication' section?
Anyway, supposedly admin user should have rights to all DBs. You can try to figure this issue out at Jelastic community
I had the same issue when connection to mongodb custom named database.
In order to succeed with the connection, I have created an user for my custom named database.
(I added the provided admin user with its password to the authorized users as the image shown).

Connect to Mongo DB on MongoLab without Authorization?

My Question:
Is there any way to connect to Mongo DB (hosted on MongoLab) without username and password ?
My Case:
I have created a free MongoLab account (https://mongolab.com) and also create new database -> collection -> document in it.
When I connect to Mongo DB (on Mongo Lab) without username and password, I was able to connect, but when I try to retrieve any data it gives me "unauthorized db:testing lock type:-1 client:...." error.
So I have created a DB User in MongLab as well and provide username and password at the time of connection. After that I am able to connect and retrieve data from Mongo DB.
MongoLab's multi-tenant database plans are on shared servers. We cannot give you the choice to forgo authentication. Even if you were ok with others seeing you data, the other tenants on the server you share would still not want you to see their data.
We have dedicated server plans where you have your own server. On those we could turn off authentication for you. Email us at support#mongolab.com.
As for your benchmarks - auth will not slow things down. The drivers do not authentication on each request, just each connection. If you use the driver properly it should all work well.
-will (MongoLab)