mongodb uri set db and authSource, but execute "db" return admin
id-id-id opened this issue · 7 comments
Hi, there is a question i want to ask you. I use mogodb driver to connector mongodb,
uri is mongodb://admin:admin@localhost:27017/test1?authSource=admin
but when i execute "db" it returns admin, not test1. and when i execute "use test1; db.a.find();" it will execute in admin, not in test1
i want to execute shell command in test1 but not admin ,what can i do?
We have the same issue, when we use jdbc:mongodb://user:pwd@localhost:27017/test?authSource=admin
, then the driver is using admin
database and we cannot do any query on test
database. We are using jars from official page which include mongojdbc4.1.jar
.
Workaround: for anybody having the same issue, we fixed it by creating another user in our test
database:
use test
db.createUser({user: 'user2', pwd: 'pwd', roles: ['readWrite']})
and then we could use the driver that authenticates through test
db: jdbc:mongodb://user2:pwd@localhost:27017/test
Thank you for writing about this.
We have created a new driver, where we improved the handling of the current database. This issue should be fixed.
It is still helpful if you can test it and write feedback.
We are also using a 'Ping' command, which was previously executed in the admin database. We moved this to the database from the URL. I know this may generate issues, on servers with a more restrictive configuration.
You can get the new driver by dropping the folder C:\Users<YourUser>.DbSchema\drivers\MongoDb.
Next time you will connect to MongoDB, the latest driver will be downloaded.
@wise-coders The issue is fixed with new driver. Thanks!
Thank you for your feedback!
@wise-coders The issue is fixed with new driver. Thanks!
I download the newest one is 4.1, where to find newer one?