I'm trying to shutdown mongodb so that I can convert it to a replica set, but I keep getting an error.
when using db.shutdownServer(), I get
"errmsg" : "not authorized on admin to execute command
I tried "use admin" and then running the command, but issue still persists.
I saw another post where they said to use db.auth(username, password) but if I type that in cmd after connecting to cluster
When I try db.auth(username, password) replacing username and password with actual values
I get
SyntaxError: missing ) after argument list
I'm still new to mongodb so any help is appreciated.
can you share the piece of code.
you can rewrite the above command with
passwordPrompt() option
db.auth( "username", passwordPrompt() )
or
mongo --username "" --password -- --authenticationMechanism SCRAM-SHA-256
Related
I followed the instructions here for setting up users...
Then from another machine I do:
mongo -u admin -p adminpassword host/collection
The response I get is:
MongoDB shell version: 2.6.10 connecting to: host/collection
2019-07-12T06:20:36.336+0000 Error: 2 { ok: 0.0, errmsg: "Auth
mechanism not specified", code: 2, codeName: "BadValue" } at
src/mongo/shell/db.js:1287 exception: login failed
Now, I suppose this is an issue with different versions but what I'm really after is to remote connect from a node script and that's failing as well but the only message is: "MongoError: Authentication failed."
Does anyone know a solution?
Ran into the same issue when using an old Mongo shell version (2.x/3.x) with a 4.0+ server. Upgrading the Mongo shell to 4.0.6+ seems to have resolved the issue.
My guess is the protocol to authenticate and specifying auth mechanisms has changed in newer server versions.
Maybe is because you've tried to connect with admin user on a different collection than admin.
Try mongo -u ADMIN_USERNAME -p ADMIN_PASSWORD HOST_IP/admin
I spun up a mongoDB droplet so that I could have a database connected to my little game. However, complications after complications have arisen.
I am connecting to the droplet through PuTTY and was previously able to invoke "mongo" then type "show dbs" to see all the current databases.
I had been altering the /etc/mongod.conf file to allow remote connecting, and since then - any command that I invoke spits back an error message:
Just through a simple show dbs - I get this.
> show dbs
2016-12-28T00:12:26.655+0000 E QUERY [thread1] Error: listDatabases failed:{
"ok" : 0,
"errmsg" : "not authorized on admin to execute command { listDatabases: 1.0 }",
"code" : 13
} :
_getErrorWithCode#src/mongo/shell/utils.js:25:13
Mongo.prototype.getDBs#src/mongo/shell/mongo.js:62:1
shellHelper.show#src/mongo/shell/utils.js:761:19
shellHelper#src/mongo/shell/utils.js:651:15
#(shellhelp2):1:1
I'm so confused as to why this is and I've been scouring the internet to find anything that could possibly resolve this.
The problem is that you are connected to a MongoDB instance that has authorization enabled and when you connected to MongoDB via the shell you didn't specify any credentials. The MongoDB shell will allow you to connect in this case but any command you type will error out.
sudo nano /etc/mongod.conf
Disable (# auth = true)
I have 2 problems. First I can't login into my MongoDB. I tried this way: Can't create backup mongodump with --db. Authentication failed but no succsess. I've tried differnt passwords and user, but I can't log in. My Mongo Server runs on an Debian 8 Server. For Uninstall and install, I used this tutorial: https://docs.mongodb.com/manual/tutorial/install-mongodb-on-debian/ . I start the debian new after every uninstall.
Can I remove the password. In the conf data, I comment auth = true. I hope you can help me.
I get this message
MongoDB shell version: 3.2.7
connecting to: 127.0.0.1:27017/test
2016-06-29T12:30:01.079+0000 E QUERY [thread1] Error: Authentication failed. :
DB.prototype._authOrThrow#src/mongo/shell/db.js:1441:20
#(auth):6:1
#(auth):1:2
exception: login failed
No authentication by default on mongo that might have to do with system privileges.
I'm trying to activate user authorization on my local Mongo installation, but authentication keeps on failing. What can be the problem? Am I missing something?
I followed the steps outlined in "Installing on Windows" and "Enable Client Access Control":
1) Added a user
>mongo admin
MongoDB shell version: 3.2.7
connecting to: admin
> db.createUser({createUser:"admin",pwd:"admin",roles:["root"]})
Successfully added user: { "createUser" : "admin", "roles" : [ "root" ] }
>
2) Enabled Client Access Control in mongod.cfg:
systemLog:
destination: file
path: c:\data\log\mongod.log
storage:
dbPath: c:\data\db
security:
authorization: enabled
3) Restarted mongod
4) Now logging in with the "right" credentials (the ones I just specified) always fails:
>mongo admin -u admin -p admin
MongoDB shell version: 3.2.7
connecting to: admin
2016-06-14T12:25:02.376+0200 E QUERY [thread1] Error: Authentication failed. :
DB.prototype._authOrThrow#src/mongo/shell/db.js:1441:20
#(auth):6:1
#(auth):1:2
exception: login failed
The error in the logfile is: SCRAM-SHA-1 authentication failed for admin on admin from client 127.0.0.1 ; AuthenticationFailed: SCRAM-SHA-1 authentication failed, storedKey mismatch
Platform is Windows 10 x64, if that matters.
MongoDB 64-bit 3.2.7 with OpenSSL.
As per the documentation, the object passed to createUser should contain a user property (along with the others):
db.createUser({ user : "admin", pwd : "admin", roles : ["root"] })
^^^^ not `createUser`
Probably you're trying to recreate the database with new login and/or password. So, you need to exclude the "/db" folder. The database path's in the docker-compose.yml file. e.g.: "volumes: - ./db:/data/db".
If someone came here with the error message, this may help:
MongoDB cannot handle several symbols;
Restrictions on Database Names for Windows
For MongoDB deployments running on Windows, database names cannot contain any of the following characters:
/\. "$*<>:|?
Also database names cannot contain the null character.
Restrictions on Database Names for Unix and Linux Systems
For MongoDB deployments running on Unix and Linux systems, database names cannot contain any of the following characters:
/\. "$
https://docs.mongodb.com/manual/reference/limits/#Restrictions-on-Field-Names
I stuck on the error 'Authentication failed' with mongoengine as well as pymongo.
Please change your password when containing the symbols.
I believe the password you entered on db.createUser doesn't match the one you entered when prompting Enter password in the mongo console. You can try to remove the user: db.dropUser('userName') and recreate the user. Make sure you remember the correct password.
I've run meteor deploy sitename : it's ok
Then I want to connect to the database whith robomongo, so i run the command :
mongo --url http://sitename.meteor.com/
I receive an url of this type :
mongodb://client-d7a066d2:8c9b29f5-180e-d57a-3ba7-1b2037c2aeb1#production-db-d1.meteor.io:27017/libreboardandy_meteor_com
This adress is valid during one minute.
In Robomongo I start a new connection, give a name and paste the url.
Then I click on the connect button.
But I have an error message...
Cannot connect to MongoD ....
Any help ?
Thanks
so try use mongo -U command ;
meteor mongo -U sitename.meteor.com
// mongodb://username:password#production-db-d1.meteor.io:27017/database_name
:
client-d7a066d2:8c9b29f5-180e-d57a-3ba7-1b2037c2aeb1
set username and password
ok click test.
Go to your project folder in your local environment (e.g. Terminal in OSX)
Type meteor mongo --url YOURDEPLOYEDAPP.meteor.com
You will get something like this:
mongodb://client-49e5fcc0:d3d4c092-adc9-4966-57a9-a321caaa6415#production-db-d2.meteor.io:27017/yourdeployedapp_meteor_com
That mongodb URL contains, in this order:
mongodb://username:password#server-address:port/database_name
So now in Robomongo (or your local DB client), create a new connection using this information, like this screenshot: