MongoDB shutdown fails with authentication turned on - mongodb

Steps:
connect to mongo shell via localhost,
use admin
switched to db admin
db.shutdownServer()
assert failed : unexpected error: "shutdownServer failed: unauthorized"
Error: Printing Stack Trace
at printStackTrace (src/mongo/shell/utils.js:37:15)
at doassert (src/mongo/shell/assert.js:6:5)
at assert (src/mongo/shell/assert.js:14:5)
at DB.shutdownServer (src/mongo/shell/db.js:346:9)
at (shell):1:4
Tue Nov 12 23:05:45.236 assert failed : unexpected error: "shutdownServer failed: unauthorized" at src/mongo/shell/assert.js:7
Any suggestion would be great. This started happening after we turned on authentication. Thanks in advance!

Well, you did not authenticate
instead of
mongo
use admin
try this :
mongo admin -u username -p password
and be sure there is a user on db.admin
http://docs.mongodb.org/manual/reference/method/db.addUser/

Related

Cubejs : Error: 19488:error:1408F10B:SSL routines:ssl3_get_record:wrong version number:c:\ws\deps\openssl\openssl\ssl\record\ssl3_record.c:332:

I am trying to connect Cubejs to MongoDB through MongoDB BI Connect.
My mongosqld command is as follows
./mongosqld --config mongosqld.conf -u useradmin -p xxxx --auth --sslMode requireSSL --sslPEMKeyFile mongo.pem
I have created mongo.pem file by referring below link
Cube.js: Error: ssl is required when using cleartext authentication using MongoDB BI Connector
My Cube.js .ENV configuration is as follows
CUBEJS_DEV_MODE=true
CUBEJS_DB_TYPE=mongobi
CUBEJS_API_SECRET= xxxxxx
CUBEJS_EXTERNAL_DEFAULT=true
CUBEJS_SCHEDULED_REFRESH_DEFAULT=true
CUBEJS_WEB_SOCKETS=true
CUBEJS_DB_HOST=localhost
CUBEJS_DB_NAME=RDM
CUBEJS_DB_USER=useradmin
CUBEJS_DB_PASS=xxxx
CUBEJS_DB_SSL=true
CUBEJS_DB_SSL_REJECT_UNAUTHORIZED=false
After trying to connect Error shown in cubejs
Runtime Error
Cube.js was unable to connect to the specified database.
The database returned the following error:
>Database Error
Error: Error: 19488:error:1408F10B:SSL routines:ssl3_get_record:wrong version number:c:\ws\deps\openssl\openssl\ssl\record\ssl3_record.c:332:
And below error in mongosqld run on powershell
2021-10-12T17:15:06.045+0000 I NETWORK [conn1] connection accepted from 127.0.0.1:61457 #1 (1 connection now open)
2021-10-12T17:15:06.056+0000 E NETWORK [conn1] handshake error: ERROR 1043 (08S01): recv handshake response error: ERROR 1043 (08S01): ssl configuration error: UseCertificateChainFile: SSL errors: 906d06c:PEM routines:PEM_read_bio:no start line
140dc009:SSL routines:SSL_CTX_use_certificate_chain_file:PEM lib
2021-10-12T17:15:06.057+0000 I NETWORK [conn1] end connection 127.0.0.1:61457 (0 connections now open)
From the error I understand that the .pem file generated is not correct. Can someone please help me in this ?

Issues starting mongodb instance via mongodb shell

I entered sudo service mongod start in my MongoDB shell (Ubuntu)
got the following error:
[js] uncaught exception: SyntaxError: unexpected token: identifier :
#(shell):1:5
Any advice?

Trouble connecting mongo to mlab (login failed)

I try to connect mongo to mlab but got this error: https://imgur.com/a/mjN2lbe
$ ./bin/mongo.exe mongo ds*****.mlab.com:****/**** -u <username> -p
MongoDB shell version v3.6.4
Enter password:
connecting to: mongodb://127.0.0.1:27017/mongo
MongoDB server version: 3.6.4
2018-04-30T21:59:20.446+0700 E QUERY [thread1] Error: Authentication failed. :
DB.prototype._authOrThrow#src/mongo/shell/db.js:1608:20
#(auth):6:1
#(auth):1:2
exception: login failed
I have already created user on mlab database like this: https://imgur.com/a/mjN2lbe but it still doesn't work. I'm 100% sure that I did not type the wrong username or password

Remote MongoLab MongoDB login failed error

I am trying to connect to a mongoLab mongoDB using mongo shell. This is the error that I am getting:
C:\Program Files\MongoDB 2.6 Standard\bin>mongo ds053332.mongolab.com:53332/stormaxdb -u abhishek -p password
MongoDB shell version: 2.6.4
connecting to: ds053332.mongolab.com:53332/stormaxdb
2015-03-18T16:44:27.740+0530 Socket recv() errno:10053 An established connection was aborted by the software in your host machine. 54.224.106.116:53332
2015-03-18T16:44:27.742+0530 SocketException: remote: 54.224.106.116:53332error: 9001 socket exception [RECV_ERROR] server [54.224.106.116:53332]
2015-03-18T16:44:27.746+0530 DBClientCursor::init call() failed
2015-03-18T16:44:27.748+0530 Error: 10276 DBClientBase::findN: transport error: ds053332.mongolab.com:53390 ns: stormaxdb.$cmd query: { getnonce: 1 } at src/mongo/sh
ell/db.js:1210
exception: login failed
I searched a lot to fix this error but did not find a concrete solution. Can anybody guide how to solve it, and why is it coming?
I faced a similar issue. It appeared that my firewall was blocking connection to mongo server. Try unblocking mongo from the firewall settings and it should work.

Error during mongo startup

When I type mongo on command prompt than output like
~$ mongo
MongoDB shell version: 2.2.3
connecting to: test
But when I type mongo 127.0.0.1:28017/stu1
output :-
MongoDB shell version: 2.2.3
connecting to: 127.0.0.1:28017/stu1
Mon Mar 10 16:56:01 DBClientCursor::init call() failed
Mon Mar 10 16:56:01 Error: Error during mongo startup. :: caused by :: 10276
DBClientBase::findN: transport error: 127.0.0.1:28017 ns: admin.$cmd query: { whatsmyuri: 1 } src/mongo/shell/mongo.js:93
exception: connect failed
OS :- ubuntu 12.04
So please help me to solve this error.
28017 is the default port for the HTTP admin interface, so if your config is allowing HTTP, you should use a web browser to access it http://127.0.0.1:28017/
You're trying to use mongo shell to access HTTP service.
To have access to the database using HTTP protocol then use ~$ mongod --rest to start the db. Now call http://127.0.0.1:28017/stu1/coll_name in the web browser which list all the documents in your collection.