Unsolved MongoServerError: Authentication failed.

  • This post is deleted!

  • @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


    # mongod.conf
    # for documentation of all options, see:
    #   http://docs.mongodb.org/manual/reference/configuration-options/
    # Where and how to store data.
      dbPath: /var/lib/mongodb
        enabled: true
    #  engine:
    #  wiredTiger:
    # where to write logging data.
      destination: file
      logAppend: true
      path: /var/log/mongodb/mongod.log
    # network interfaces
      port: 27017
    # how the process runs
      timeZoneInfo: /usr/share/zoneinfo
      authorization: enabled
    ## Enterprise-Only Options:

    Is these right?

  • @napishtim yes. Did you restart MongoDB after making those changes?

  • @phenomlab

    mongo -u admin -p myadminpassoword --authenticationDatabase=admin
    MongoDB shell version v5.0.8
    connecting to: mongodb://
    Error: couldn't connect to server, connection attempt failed: SocketException: Error connecting to :: caused by :: Connection refused :
    [email protected]/mongo/shell/mongo.js:372:17
    exception: connect failed
    exiting with code 1
    [email protected]:~/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
    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
        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?

  • Global Moderator Plugin & Theme Dev

    Have you checked if mongo is running?

    sudo systemctl status mongod

  • @PitaJ said in MongoServerError: Authentication failed.:

    sudo systemctl status mongod

    [email protected]:~$ 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

    [email protected]:~$ mongo -u admin -p (myadminpassword) --authenticationDatabase=admin
    MongoDB shell version v5.0.8
    connecting to: mongodb://
    Error: Authentication failed. :
    [email protected]/mongo/shell/mongo.js:372:17
    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.

  • @phenomlab
    Of course I had created it.

  • @napishtim Ok - have you tried the password you believe you set in uppercase, or with variations ?

  • @phenomlab My password consists of upper case letters, numbers and lower case letters.

Suggested Topics

  • 9
  • 1
  • 11
  • 2
  • 2
| | |