Recovering or changing replica set password

I inherited a mongoDB replica set running mongo 4.2.25 that is associated with a graylog cluster (syslog management software). In order to update other parts of the graylog cluster I need to update the mongo replica set. The issue is that I don’t have any documentation for the actual mongo admin password, only the password for the actual graylog db user. Is there any way I can recover or reset the password for a mongo replica set, or am I going to have to remove and re-create the entire thing?
This is running on RHEL 8 on a three-node cluster.
Here is my mongod.conf file

# for documentation of all options, see:

# where to write logging data.
  destination: file
  logAppend: true
  path: /var/log/mongodb/mongod.log

# Where and how to store data.
  dbPath: /var/lib/mongo
    enabled: true
#  engine:
#  wiredTiger:

# how the process runs
  fork: true  # fork and run in background
  pidFilePath: /var/run/mongodb/  # location of pidfile
  timeZoneInfo: /usr/share/zoneinfo

# network interfaces
  port: 27017
  bindIp:, # Enter,:: to bind to all IPv4 and IPv6 addresses or, alternatively, use the net.bindIpAll setting.

  keyFile: /var/lib/mongo/mongodb-keyfile
  authorization: enabled


  replSetName: rs01


## Enterprise-Only Options


type or paste code here

Hi @Danny_McCaslin and welcome to the community!
If I understand correctly your question, you can use this workaround:

I hope it is useful!

Best regards

The problem is that when I comment out the security parameter the primary shows itself as a secondary when I log in and I still can’t add a user. I get a response from the server

"not master and slaveOk=false"

Hi @Danny_McCaslin,
You need to :

  • comment the security parameter in all the instance that compose the replica set
  • restart the instance to apply the changes
  • point to the primary instance for create user and repeat the step in reverse.


This topic was automatically closed 5 days after the last reply. New replies are no longer allowed.