Mongodb Authorisation.

Solved General
  • Error: couldn’t add user: there are no users authenticated :

    Above error is what I receive when i try to add a user or showdbs for example.

    This is a clean install of ubuntu 20.04 and all on a new drive.

    Things is I thought I am sure I already added a user and db previously. Now this when i try to install nodebb again. Any ideas? Security is auth=true in mongodb.conf

  • @Sampo2910 this is because you have the below in your mongod.conf

      authorization: enabled

    This forces the database to only accept connections or direct commands if you authenticate first. If you look at the guide, the ordering of steps is to add the users in the database before enabling the authorization.

    Not that this matters as such but can be confusing if you enable this setting before creating the users.

  • @Sampo2910 What do you get from the command below

    mongo -u admin -p password --authenticationDatabase=admin

    Obviously, replace password with the real one.

  • @phenomlab
    When i used that and replaced details I get

    MongoDB shell version v3.6.8
    connecting to: mongodb://
    Implicit session: session { "id" : UUID("33e5efda-709f-43a9-ab1f-6c2f5be24199") }
    MongoDB server version: 3.6.8
    Server has startup warnings:
    2022-12-02T18:33:17.917+0200 I STORAGE  [initandlisten]
    2022-12-02T18:33:17.917+0200 I STORAGE  [initandlisten] ** WARNING: Using the XFS filesystem is strongly recommended with the WiredTiger storage engine
    2022-12-02T18:33:17.917+0200 I STORAGE  [initandlisten] **          See
    > show dbs
    admin          0.000GB
    cod4xwebadmin  0.002GB
    config         0.000GB
    local          0.000GB

    So i can go in there that way and i managed to create a user etc. Previously i just used ‘mongo’ and I could do all. What did change? I am using a newer version of Mongo than before. I know that.

  • @Sampo2910 this is because you have the below in your mongod.conf

      authorization: enabled

    This forces the database to only accept connections or direct commands if you authenticate first. If you look at the guide, the ordering of steps is to add the users in the database before enabling the authorization.

    Not that this matters as such but can be confusing if you enable this setting before creating the users.

  • phenomlabundefined phenomlab has marked this topic as solved on
  • @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
  • @Sampo2910 interesting. What OS are you using?

  • @phenomlab

    Ubuntu 20.04
    MongoDB shell version v3.6.8

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

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

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

  • @phenomlab

    # mongodb.conf
    # Where to store the data.
    #where to log
    bind_ip =
    #port = 27017
    # Enable journaling,
    # 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 =
    # Slave only: specify a single database to replicate
    #only =
    # or
    #master = true
    #source =
    # Address of a server to pair with.
    #pairwith = <server:port>
    # Address of arbiter server.
    #arbiter = <server:port>
    # Automatically resync if slave data is stale
    # 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
  • @Sampo2910 I’ve only ever installed MongoDB using the NodeBB guide

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

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

  • @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://
    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
    > show dbs
    uncaught exception: Error: Failed to acquire database information from privileges :
    > exit
  • @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

    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.

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

Did this solution help you?
Did you find the suggested solution useful? Why not buy me a coffee? It's a nice gesture, and a great way to show your appreciation💗

  • 2 Votes
    11 Posts

    @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
    Edit the /etc/resovel.conf file

    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?

  • 4 Votes
    10 Posts

    @phenomlab It is all because of a theme 😄

  • Embeds

    4 Votes
    4 Posts

    @OT Are you testing embeds, or did you insert this link for another purpose? For clarity, this isn’t a testing category 🙂

  • Nodebb design

    Solved General
    1 Votes
    2 Posts

    @Panda said in Nodebb design:

    One negative is not being so good for SEO as more Server side rendered forums, if web crawlers dont run the JS to read the forum.

    From recollection, Google and Bing have the capability to read and process JS, although it’s not in the same manner as a physical person will consume content on a page. It will be seen as plain text, but will be indexed. However, it’s important to note that Yandex and Baidu will not render JS, although seeing as Google has a 90% share of the content available on the web in terms of indexing, this isn’t something you’ll likely lose sleep over.

    @Panda said in Nodebb design:

    The “write api” is preferred for server-to-server interactions.

    This is mostly based around overall security - you won’t typically want a client machine changing database elements or altering data. This is why you have “client-side” which could be DOM manipulation etc, and “server-side” which performs more complex operations as it can communicate directly with the database whereas the client cannot (and if it can, then you have a serious security flaw). Reading from the API is perfectly acceptable on the client-side, but not being able to write.

    A paradigm here would be something like SNMP. This protocol exists as a UDP (UDP is very efficient, as it is “fire and forget” and does not wait for a response like TCP does) based service which reads performance data from a remote source, thus enabling an application to parse that data for use in a monitoring application. In all cases, SNMP access should be “RO” (Read Only) and not RW (Read Write). It is completely feasible to assume complete control over a firewall for example by having RW access to SNMP and then exposing it to the entire internet with a weak passphrase.

    You wouldn’t do it (at least, I hope you wouldn’t) and the same ethic applies to server-side rendering and the execution of commands.

  • 2 Votes
    6 Posts

    @dave1904 I’d start by adding a console.log function to hookData so you can see what is being returned

    return hookData; console.log(hookData):
  • 2 Votes
    2 Posts

    @dave1904 that’s a really good point actually. I know it was there previously on Persona, but you’re right - no such function exists on harmony.

    However, putting something in place to mimick the behaviour of Persona won’t be hard from the js standpoint, although I wonder if perhaps we should ask the NodeBB developers is this feature was overlooked?

  • 3 Votes
    2 Posts

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