0
votes

I have a mLab mongo database and a nodejs server set up. However, when I try to push something to the database it gives me the following error:

not authorized on DATABASE to execute command { insert: \"users\", documents: [ { _id: ObjectId('RANDOMID'), username: \"USERNAME\", email: \"EMAIL\", 1.0: 0 } ], ordered: true }"

I am the only user and I have the dbOwner role.

package.json:

{
  "name": "api",
  "version": "1.0.0",
  "private": true,
  "main": "app.js",
  "scripts": {
    "start": "node app.js"
  },
  "dependencies": {
    "express": "^4.16.3",
    "mocha": "^5.1.1",
    "mongodb": "^3.1.0-beta4",
    "mongoose": "^5.0.11",
    "pug": "^2.0.3",
    "underscore": "^1.8.3"
  }
}
1
Check out docs.mlab.com/connecting/#help and if it doesn't help, [email protected] will be happy to help troubleshoot. - Adam Harrison

1 Answers

1
votes

"cannot authenticate code 18" means your driver is incompatible with the version of your database running with mLab. If your driver is using MONGODB-CR and your database is running SCRAM-SHA-1 as the authentication mechanism, you'll get this error.

Confirm your driver is compatible with the version of your mLab database server.

https://docs.mongodb.com/ecosystem/drivers/driver-compatibility-reference/