lost admin password

  • Ok, the inevitable happened.
    While installing the email plugin I've been logged out and now I can't remember the password and I realised the email plugin (smtp) is not working (it should send me a reset link)

    @julian @baris

  • Admin

    You can just create another account and give it admin privileges from redis-cli. Then you can change the password of your original account with this new admin.

    First create a user as normal. Note down their username.

    Now go into redis-cli and find the gid of the admin group.

    hget group:gid administrators (1)

    Then get the uid of the new user

    hget username:uid <username> (2)

    Now add the uid of the user name to the admin group.

    sadd gid:<replace with value from step 1>:members <replace with value from step 2>

    Let me know if that helps. Not sure why the email plugin is not working.

  • hget group:gid administrators

    @baris What if I even managed to lock new member registration ? :)

  • Admin

    hset config allowRegistration 1 should enable it back.

  • @baris it replies with (integer) 0

  • Admin

    That's fine can you get to the register form after running that?

  • @baris what's the url?

  • Admin

  • @baris OK, I needed to restart nodebb - was getting a 403 on that

  • sadd gid:<replace with value from step 1>:members <replace with value from step 2>

    @baris OK, I'm in. now about that smtp email plugin...

  • Admin

    Email plugins are @julian 's area of expertise so I am going to let him handle that :grinning:

  • @baris @julian Anyway, the mailgun plugin works (i previously disabled it) - local email plugin doesn't

  • @baris said:

    hget group:gid administrators

    hi,when I run

    hget group:gid administrators
    it's return nil


  • Admin

    Hello @colornote, sorry to hear you got locked out!

    The instructions have changed as the schema has changed.


    1. First create a user as normal. Note down their username.
    2. Get the uid of the new user: hget username:uid <username>
    3. sadd group:administrators:members <replace with value from step 2>

  • @julian Thank you!
    I use another way which you offer, and reset the admin's password successfully.

    To reset the password even if no email is installed:

    1. Go to /reset and key in your email. It won't send out the password reset email, but a key will be generated. This key expires after 2 hours.
    2. redis-cli to enter the redis console. If redis is installed on a different port, host, or socket, use -p, -h, and -s respectively
    3. hgetall reset:uid, and locate the reset id corresponding to your uid
    4. Go to /reset/{reset-uid}

  • Swedes

    I use mongodb, here is the solution: // I just wanted to share :P

    // Show collections
    show collections
    // Find the userid you want to add to the
    db.objects.find( { "_key" : "username:uid" } )
    // Find members id in administrators group
    db.objects.find( { "_key" : "group:administrators:members" } )
    // To update, 3 was my userid :)
    db.objects.update( { "_id" : ObjectId("54022b7f60757d4944a05931") }, { "_key" : "group:administrators:members", "members" : [ "1", "2", "3" ] }, { upsert: true }

    More info here ;)

  • Slight Update To Jenkler's approach, not sure in which version this changed* but:
    modify the key "value" with the array of users you want to give admin permissions to
    "value" : [ "1", "2" ]

    as opposed to
    "members" : ["1","2"]

    Note: the ObjectId() used in the first parameter of the update query is the id of the object found from the find query { "_key" : "group:administrators:members" }
    If you have rockmongo you may also just edit the result that you find from { "_key" : "group:administrators:members" }

  • @Jenkler Hey thanks you very much this worked like a charm for me..great help!!

  • Swedes

    Np, Its nice to give back to the community ;)

Log in to reply

Looks like your connection to NodeBB was lost, please wait while we try to reconnect.