Skip to content

Mongodb Authorisation.

Solved General
17 2 5.4k 1
  • @phenomlab

    I do not really understand because I have always had it enabled in the past and was still able to use commands by just using ‘mongo’ in the shell. Whilst enabled I was also able to install NodeBB and create users. Just this time round I cannot even though I have followed instruction the same way.

    The other app i use instructs me to enable and at no point says to turn it off. That’s the same with nodebb install instructions.

    I do not have mongod.conf but mongodb.conf. The security looks like this:

    # Turn on/off security.  Off is currently the default
    #noauth = true
    auth = true
    
    wrote on last edited by
    #6

    @Sampo2910 interesting. What OS are you using?

  • @Sampo2910 interesting. What OS are you using?

    wrote on last edited by
    #7

    @phenomlab

    Ubuntu 20.04
    MongoDB shell version v3.6.8

  • @phenomlab

    Ubuntu 20.04
    MongoDB shell version v3.6.8

    wrote on last edited by
    #8

    @Sampo2910 that conf file doesn’t look right to me. From where did you install MongoDB?

  • @Sampo2910 that conf file doesn’t look right to me. From where did you install MongoDB?

    wrote on last edited by
    #9

    @phenomlab It is the one i have used for years and the way i did it for years.

    https://linuxhint.com/install_mongodb_ubuntu_20_04/

  • @phenomlab It is the one i have used for years and the way i did it for years.

    https://linuxhint.com/install_mongodb_ubuntu_20_04/

    wrote on last edited by
    #10

    @Sampo2910 hmm. Nothing wrong with that guide, but I’ve never seen a conf file from MongoDB that looks like it.

    Can you send me the remainder of the file?

  • @Sampo2910 hmm. Nothing wrong with that guide, but I’ve never seen a conf file from MongoDB that looks like it.

    Can you send me the remainder of the file?

    wrote on last edited by
    #11

    @phenomlab

    # mongodb.conf
    
    # Where to store the data.
    dbpath=/var/lib/mongodb
    
    #where to log
    logpath=/var/log/mongodb/mongodb.log
    
    logappend=true
    
    bind_ip = 127.0.0.1
    #port = 27017
    
    # Enable journaling, http://www.mongodb.org/display/DOCS/Journaling
    journal=true
    
    # Enables periodic logging of CPU utilization and I/O wait
    #cpu = true
    
    # Turn on/off security.  Off is currently the default
    #noauth = true
    auth = true
    
    # Verbose logging output.
    #verbose = true
    
    # Inspect all client data for validity on receipt (useful for
    # developing drivers)
    #objcheck = true
    
    # Enable db quota management
    #quota = true
    
    # Set diagnostic logging level where n is
    #   0=off (default)
    #   1=W
    #   2=R
    #   3=both
    #   7=W+some reads
    #diaglog = 0
    
    # Diagnostic/debugging option
    #nocursors = true
    
    # Ignore query hints
    #nohints = true
    
    # Disable the HTTP interface (Defaults to localhost:27018).
    #nohttpinterface = true
    
    # Turns off server-side scripting.  This will result in greatly limited
    # functionality
    #noscripting = true
    
    # Turns off table scans.  Any query that would do a table scan fails.
    #notablescan = true
    
    # Disable data file preallocation.
    #noprealloc = true
    
    # Specify .ns file size for new databases.
    # nssize = <size>
    
    # Accout token for Mongo monitoring server.
    #mms-token = <token>
    
    # Server name for Mongo monitoring server.
    #mms-name = <server-name>
    
    # Ping interval for Mongo monitoring server.
    #mms-interval = <seconds>
    
    # Replication Options
    
    # in replicated mongo databases, specify here whether this is a slave or master
    #slave = true
    #source = master.example.com
    # Slave only: specify a single database to replicate
    #only = master.example.com
    # or
    #master = true
    #source = slave.example.com
    
    # Address of a server to pair with.
    #pairwith = <server:port>
    # Address of arbiter server.
    #arbiter = <server:port>
    # Automatically resync if slave data is stale
    #autoresync
    # Custom size for replication operation log.
    #oplogSize = <MB>
    # Size limit for in-memory storage of op ids.
    #opIdMem = <bytes>
    
    # SSL options
    # Enable SSL on normal ports
    #sslOnNormalPorts = true
    # SSL Key file and password
    #sslPEMKeyFile = /etc/ssl/mongodb.pem
    #sslPEMKeyPassword = pass
    
    
  • @phenomlab

    # mongodb.conf
    
    # Where to store the data.
    dbpath=/var/lib/mongodb
    
    #where to log
    logpath=/var/log/mongodb/mongodb.log
    
    logappend=true
    
    bind_ip = 127.0.0.1
    #port = 27017
    
    # Enable journaling, http://www.mongodb.org/display/DOCS/Journaling
    journal=true
    
    # Enables periodic logging of CPU utilization and I/O wait
    #cpu = true
    
    # Turn on/off security.  Off is currently the default
    #noauth = true
    auth = true
    
    # Verbose logging output.
    #verbose = true
    
    # Inspect all client data for validity on receipt (useful for
    # developing drivers)
    #objcheck = true
    
    # Enable db quota management
    #quota = true
    
    # Set diagnostic logging level where n is
    #   0=off (default)
    #   1=W
    #   2=R
    #   3=both
    #   7=W+some reads
    #diaglog = 0
    
    # Diagnostic/debugging option
    #nocursors = true
    
    # Ignore query hints
    #nohints = true
    
    # Disable the HTTP interface (Defaults to localhost:27018).
    #nohttpinterface = true
    
    # Turns off server-side scripting.  This will result in greatly limited
    # functionality
    #noscripting = true
    
    # Turns off table scans.  Any query that would do a table scan fails.
    #notablescan = true
    
    # Disable data file preallocation.
    #noprealloc = true
    
    # Specify .ns file size for new databases.
    # nssize = <size>
    
    # Accout token for Mongo monitoring server.
    #mms-token = <token>
    
    # Server name for Mongo monitoring server.
    #mms-name = <server-name>
    
    # Ping interval for Mongo monitoring server.
    #mms-interval = <seconds>
    
    # Replication Options
    
    # in replicated mongo databases, specify here whether this is a slave or master
    #slave = true
    #source = master.example.com
    # Slave only: specify a single database to replicate
    #only = master.example.com
    # or
    #master = true
    #source = slave.example.com
    
    # Address of a server to pair with.
    #pairwith = <server:port>
    # Address of arbiter server.
    #arbiter = <server:port>
    # Automatically resync if slave data is stale
    #autoresync
    # Custom size for replication operation log.
    #oplogSize = <MB>
    # Size limit for in-memory storage of op ids.
    #opIdMem = <bytes>
    
    # SSL options
    # Enable SSL on normal ports
    #sslOnNormalPorts = true
    # SSL Key file and password
    #sslPEMKeyFile = /etc/ssl/mongodb.pem
    #sslPEMKeyPassword = pass
    
    
    wrote on last edited by
    #12

    @Sampo2910 I’ve only ever installed MongoDB using the NodeBB guide

    https://docs.nodebb.org/installing/os/ubuntu/

  • @Sampo2910 I’ve only ever installed MongoDB using the NodeBB guide

    https://docs.nodebb.org/installing/os/ubuntu/

    wrote on last edited by
    #13

    @phenomlab

    All broken at the moment. Will figure it out 🙂 Using that guide above stopped my other app and a ton of errors on install 🙂 Also this is now in nodebb. All for another day 🙂

    2022-12-03 01_31_24-Extend _ Plugins _ NodeBB Admin Control Panel.png

  • @phenomlab

    All broken at the moment. Will figure it out 🙂 Using that guide above stopped my other app and a ton of errors on install 🙂 Also this is now in nodebb. All for another day 🙂

    2022-12-03 01_31_24-Extend _ Plugins _ NodeBB Admin Control Panel.png

    wrote on last edited by
    #14

    @Sampo2910 what were the errors? I’ve never had an issue with it?

  • @Sampo2910 what were the errors? I’ve never had an issue with it?

    wrote on last edited by
    #15

    @phenomlab Only way all works is if i use node v12 anything more i get errors like that on the page.

    MongoDB shell version v5.0.14 and MongoDB server version: 3.6.8 is what I am using. I get a warning that they do not match but i cant seem to update mongo server version either.

    I am not at a level where I understand to be honest. Node, npm, nvm mongo…things work on some versions and not others. Updating to the latest just breaks things.

    smiley@fmjcod4:~$ mongo
    MongoDB shell version v5.0.14
    connecting to: mongodb://127.0.0.1:27017/?compressors=disabled&gssapiServiceName=mongodb
    Implicit session: session { "id" : UUID("b7326d9b-2817-403e-b072-2f0f5330761d") }
    MongoDB server version: 3.6.8
    WARNING: shell and server versions do not match
    ================
    Warning: the "mongo" shell has been superseded by "mongosh",
    which delivers improved usability and compatibility.The "mongo" shell has been deprecated and will be removed in
    an upcoming release.
    For installation instructions, see
    https://docs.mongodb.com/mongodb-shell/install/
    ================
    > show dbs
    uncaught exception: Error: Failed to acquire database information from privileges :
    _getErrorWithCode@src/mongo/shell/utils.js:25:13
    Mongo.prototype._getDatabaseNamesFromPrivileges@src/mongo/shell/mongo.js:69:15
    Mongo.prototype.getDBs/<@src/mongo/shell/mongo.js:134:31
    Mongo.prototype.getDBs@src/mongo/shell/mongo.js:97:12
    shellHelper.show@src/mongo/shell/utils.js:956:13
    shellHelper@src/mongo/shell/utils.js:838:15
    @(shellhelp2):1:1
    > exit
    bye
    
  • @phenomlab Only way all works is if i use node v12 anything more i get errors like that on the page.

    MongoDB shell version v5.0.14 and MongoDB server version: 3.6.8 is what I am using. I get a warning that they do not match but i cant seem to update mongo server version either.

    I am not at a level where I understand to be honest. Node, npm, nvm mongo…things work on some versions and not others. Updating to the latest just breaks things.

    smiley@fmjcod4:~$ mongo
    MongoDB shell version v5.0.14
    connecting to: mongodb://127.0.0.1:27017/?compressors=disabled&gssapiServiceName=mongodb
    Implicit session: session { "id" : UUID("b7326d9b-2817-403e-b072-2f0f5330761d") }
    MongoDB server version: 3.6.8
    WARNING: shell and server versions do not match
    ================
    Warning: the "mongo" shell has been superseded by "mongosh",
    which delivers improved usability and compatibility.The "mongo" shell has been deprecated and will be removed in
    an upcoming release.
    For installation instructions, see
    https://docs.mongodb.com/mongodb-shell/install/
    ================
    > show dbs
    uncaught exception: Error: Failed to acquire database information from privileges :
    _getErrorWithCode@src/mongo/shell/utils.js:25:13
    Mongo.prototype._getDatabaseNamesFromPrivileges@src/mongo/shell/mongo.js:69:15
    Mongo.prototype.getDBs/<@src/mongo/shell/mongo.js:134:31
    Mongo.prototype.getDBs@src/mongo/shell/mongo.js:97:12
    shellHelper.show@src/mongo/shell/utils.js:956:13
    shellHelper@src/mongo/shell/utils.js:838:15
    @(shellhelp2):1:1
    > exit
    bye
    
    wrote on last edited by
    #16

    @Sampo2910 yes, that does indeed look a mess! I don’t think nodeJS at version 12 for NodeBB is even supported anymore. I asked a similar question but so long ago

    https://community.nodebb.org/topic/16532/supported-version-of-nodejs

    Plus, the version of MongoDB started (3.x) is also really old. I seem to recall you using an app which is considered legacy and requires older versions of software, but I think the two together are going to cause you significant issues - clearly which you’re seeing now.

    My suggestion would be to keep these on separate machines.

  • @phenomlab Only way all works is if i use node v12 anything more i get errors like that on the page.

    MongoDB shell version v5.0.14 and MongoDB server version: 3.6.8 is what I am using. I get a warning that they do not match but i cant seem to update mongo server version either.

    I am not at a level where I understand to be honest. Node, npm, nvm mongo…things work on some versions and not others. Updating to the latest just breaks things.

    smiley@fmjcod4:~$ mongo
    MongoDB shell version v5.0.14
    connecting to: mongodb://127.0.0.1:27017/?compressors=disabled&gssapiServiceName=mongodb
    Implicit session: session { "id" : UUID("b7326d9b-2817-403e-b072-2f0f5330761d") }
    MongoDB server version: 3.6.8
    WARNING: shell and server versions do not match
    ================
    Warning: the "mongo" shell has been superseded by "mongosh",
    which delivers improved usability and compatibility.The "mongo" shell has been deprecated and will be removed in
    an upcoming release.
    For installation instructions, see
    https://docs.mongodb.com/mongodb-shell/install/
    ================
    > show dbs
    uncaught exception: Error: Failed to acquire database information from privileges :
    _getErrorWithCode@src/mongo/shell/utils.js:25:13
    Mongo.prototype._getDatabaseNamesFromPrivileges@src/mongo/shell/mongo.js:69:15
    Mongo.prototype.getDBs/<@src/mongo/shell/mongo.js:134:31
    Mongo.prototype.getDBs@src/mongo/shell/mongo.js:97:12
    shellHelper.show@src/mongo/shell/utils.js:956:13
    shellHelper@src/mongo/shell/utils.js:838:15
    @(shellhelp2):1:1
    > exit
    bye
    
    wrote on last edited by
    #17

    @Sampo2910 I just saw this on the NodeBB community site and it seems very much in line with the issue you are experiencing. Worth a look I think

    https://community.nodebb.org/topic/16826/does-nodebb-work-with-mongodb-6-0


Did this solution help you?
Did you find the suggested solution useful? Support 💗 Sudonix with a coffee ☕
If your organisation needs deeper expertise around infrastructure, security, or technology leadership, learn more about Phenomlab Ltd. Many of the deeper technical guides behind Sudonix are published there.

Related Topics
  • Mongo Completely Broken.

    General mongodb
    20
    3 Votes
    20 Posts
    6k Views
    phenomlab
    @Sampo2910 said in Mongo Completely Broken.: I can see you cringing Yes, that does make me slightly uncomfortable but OK.
  • Mongodb or Redis

    General database mongodb redis
    29
    11 Votes
    29 Posts
    12k Views
    phenomlab
    @Madchatthew still a great catch.
  • Is my Mongodb installation correct?

    Solved General mongodb
    27
    4
    13 Votes
    27 Posts
    13k Views
    ahmed
    [image: yuuuuu.png]
  • mongodb backup problem

    Moved Configure mongodb
    3
    1
    1 Votes
    3 Posts
    1k Views
    phenomlab
    You might want to also review this post https://sudonix.org/topic/389/mongodb-backup-script
  • mongodb replica set

    Configure mongodb docker ansible
    11
    2 Votes
    11 Posts
    4k Views
    phenomlab
    @veronikya said in mongodb replica set: The host’s local dns resolution is not configured. The problem of the host’s hosts being unable to be resolved in docker has been solved. Surprisingly Solution: Edit the /etc/resovel.conf file Add 127.0.0.53 One immediate issue I can think of here is that editing resolv.conf directly is no longer supported and not recommended (because the changes do not survive a reboot) - unless you install the resolvconf package?
  • 3 Votes
    2 Posts
    982 Views
    phenomlab
    @DownPW This isn’t something I have readily available, and because I’m not entirely familiar with the database structure of NodeBB, it’s something that would require research and development in terms of script. I think it’d be quicker to ask this in the NodeBB forums.
  • Nodebb: failed to restore a mongo dump

    Solved Configure mongodb
    2
    1 Votes
    2 Posts
    1k Views
    DownPW
    @phenomlab In fact I specified the sub rep and not the rep DON’T DO THIS: nodebb@nodebbpwclonedb:~/nodebb$ sudo mongorestore --username admin --password XXXXXXXXXXXXXX --nsInclude nodebb.objects --drop /home/nodebb/nodebb_DB_20230107/nodebb/ BUT THIS : nodebb@nodebbpwclonedb:~/nodebb$ sudo mongorestore --username admin --password XXXXXXXXXXXXXX --nsInclude nodebb.objects --drop /home/nodebb/nodebb_DB_20230107/
  • mongorestore "E11000 duplicate key error collection"

    Solved Configure mongodb restore
    1
    1 Votes
    1 Posts
    2k Views
    No one has replied