MongoServerError: Authentication failed.
-
@phenomlab said in MongoServerError: Authentication failed.:
Did you complete steps in terms of setting up and securing MongoDB as per the documentation ?
You mean I need type:
sudo vim /etc/mongod.conf
Then
# mongod.conf # for documentation of all options, see: # http://docs.mongodb.org/manual/reference/configuration-options/ # Where and how to store data. storage: dbPath: /var/lib/mongodb journal: enabled: true # engine: # wiredTiger: # where to write logging data. systemLog: destination: file logAppend: true path: /var/log/mongodb/mongod.log # network interfaces net: port: 27017 bindIp: 127.0.0.1 # how the process runs processManagement: timeZoneInfo: /usr/share/zoneinfo #security: authorization: enabled #operationProfiling: #replication: #sharding: ## Enterprise-Only Options: #auditLog: #snmp:
Is these right?
-
@napishtim yes. Did you restart MongoDB after making those changes?
-
mongo -u admin -p myadminpassoword --authenticationDatabase=admin MongoDB shell version v5.0.8 connecting to: mongodb://127.0.0.1:27017/?authSource=admin&compressors=disabled&gssapiServiceName=mongodb Error: couldn't connect to server 127.0.0.1:27017, connection attempt failed: SocketException: Error connecting to 127.0.0.1:27017 :: caused by :: Connection refused : connect@src/mongo/shell/mongo.js:372:17 @(connect):2:6 exception: connect failed exiting with code 1
napishtim@napishtim-M14xR1:~/nodebb$ ./nodebb start 2022-06-04T08:29:59.510Z [74573] - info: Launching web installer on port 4567 2022-06-04T08:30:24.079Z [74573] - info: Web installer listening on http://0.0.0.0:4567 2022-06-04T08:31:01.964Z [74573] - info: Starting setup process 2022-06-04T08:31:04.300Z [74701] - info: NodeBB Setup Triggered via Command Line Welcome to NodeBB v2.0.0! This looks like a new installation, so you'll have to answer a few questions about your environment before we can proceed. Press enter to accept the default setting (shown in brackets). 2022-06-04T08:31:04.322Z [74701] - info: [install/checkSetupFlagEnv] checking env vars for setup info... 2022-06-04T08:31:04.660Z [74701] - info: Now configuring mongo database: 2022-06-04T08:31:35.307Z [74701] - warn: NodeBB Setup Aborted. MongoServerSelectionError: connect ECONNREFUSED 127.0.0.1:27017 at Timeout._onTimeout (/home/napishtim/nodebb/node_modules/mongodb/lib/sdam/topology.js:318:38) at listOnTimeout (node:internal/timers:559:17) at processTimers (node:internal/timers:502:7)
It causes Connection refused. How can I do for these?
-
Have you checked if mongo is running?
sudo systemctl status mongod
-
@PitaJ said in MongoServerError: Authentication failed.:
sudo systemctl status mongod
napishtim@napishtim-M14xR1:~$ sudo systemctl status mongod [sudo] napishtim 的密码: ● mongod.service - MongoDB Database Server Loaded: loaded (/lib/systemd/system/mongod.service; enabled; vendor preset: enabled) Active: active (running) since Sat 2022-06-04 16:59:21 CST; 20h ago Docs: https://docs.mongodb.org/manual Main PID: 76231 (mongod) Memory: 150.1M CGroup: /system.slice/mongod.service └─76231 /usr/bin/mongod --config /etc/mongod.conf 6月 04 16:59:21 napishtim-M14xR1 systemd[1]: Started MongoDB Database Server.
I had repaired securing MongoDB. But I can not verify the administrative user created earlier can connect
napishtim@napishtim-M14xR1:~$ mongo -u admin -p (myadminpassword) --authenticationDatabase=admin MongoDB shell version v5.0.8 connecting to: mongodb://127.0.0.1:27017/?authSource=admin&compressors=disabled&gssapiServiceName=mongodb Error: Authentication failed. : connect@src/mongo/shell/mongo.js:372:17 @(connect):2:6 exception: connect failed exiting with code 1
-
@napishtim did you create the administrator account under the admin database or nodebb ? If under nodebb but not admin, then this won't work.
-
@napishtim Ok - have you tried the password you believe you set in uppercase, or with variations ?