`authdb` option not working
See original GitHub issueusing
var connectionString = 'mongodb://' + config.database.username + ':' + config.database.password + '@' + config.database.host + ':' + config.database.port + '/' + dbname;
var connection = mongoose.createConnection(connectionString);
everything is replaced fine. user is create via mongo shell db.addUser() and has role ‘readWriteAnyDatabase’. User can connect via mongo shell and query the db. But not via mongoose.
MongoError: not authorized for query on punch.shops
>> at Object.toError (/var/www/virtual/punch/html/punch/node_modules/mongoose/node_modules/mongodb/lib/mongodb/utils.js:110:11)
>> at /var/www/virtual/punch/html/punch/node_modules/mongoose/node_modules/mongodb/lib/mongodb/cursor.js:634:54
>> at Cursor.close (/var/www/virtual/punch/html/punch/node_modules/mongoose/node_modules/mongodb/lib/mongodb/cursor.js:903:5)
>> at commandHandler (/var/www/virtual/punch/html/punch/node_modules/mongoose/node_modules/mongodb/lib/mongodb/cursor.js:634:21)
>> at /var/www/virtual/punch/html/punch/node_modules/mongoose/node_modules/mongodb/lib/mongodb/db.js:1670:9
>> at Server.Base._callHandler (/var/www/virtual/punch/html/punch/node_modules/mongoose/node_modules/mongodb/lib/mongodb/connection/base.js:382:41)
>> at /var/www/virtual/punch/html/punch/node_modules/mongoose/node_modules/mongodb/lib/mongodb/connection/server.js:472:18
>> at MongoReply.parseBody (/var/www/virtual/punch/html/punch/node_modules/mongoose/node_modules/mongodb/lib/mongodb/responses/mongo_reply.js:68:5)
>> at null.<anonymous> (/var/www/virtual/punch/html/punch/node_modules/mongoose/node_modules/mongodb/lib/mongodb/connection/server.js:430:20)
>> at EventEmitter.emit (events.js:95:17)
>> Exited with code: 8.
Issue Analytics
- State:
- Created 10 years ago
- Comments:25
Top Results From Across the Web
MongoError: auth failed mongoose connection string
I installed MEAN from MEAN packaged by Bitnami for windows 7 using the following password: 123456. Syntax for connection string to connect ...
Read more >Connection String URI Format — MongoDB Manual
Refer to the Drivers documentation. This connection string option is not available for the mongo shell. Use the command-line option instead. New in...
Read more >Managing the Authorization Database in OS X Mavericks
The security authorizationdb command has three options: ... At next reboot, the OS will detect that /var/db/auth.db does not exist and ...
Read more >External Auth db not updating password - Moodle in English
I have external db authorization turned on for the site, and have confirmed that users who are in the external db *can* log...
Read more >Working With the Authentication Database - Oracle Help Center
The Authentication Database, also referred to as auth-db, represents a ... For example, the configuration below is equivalent to not specifying servicename: ...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
After hours of debugging I found the solution: use the authdb option.
For some reason I am able to connect to the admin database and create records with no problems.
This is how I am connecting: