Reset CouchDB admin Password in Linux

Reset CouchDB admin Password in Linux

If you have installed CouchDB database in your system and you forgot the admin password, you can reset it by editing a configuration file.

This tutorial explains how to reset CouchDB admin password in Linux. Commands have been tested on Ubuntu 20.04 LTS.

Reset admin password

CouchDB stores usernames and passwords for administrator accounts in configuration INI files. On Linux systems, these files usually located in /opt/couchdb/etc/local.ini or /opt/couchdb/etc/local.d/10-admins.ini. You can find them by using the following commands:

sudo find / -wholename '*/couchdb/*local.ini'
sudo find / -wholename '*/couchdb/*10-admins.ini'

If you find both files, you need to decide which to use. Both files contains [admins] section which is used to specify username and password for administrator account. The settings in a 10-admins.ini file override the settings in a local.ini file. In most cases, admin username and password specified in 10-admins.ini file. You can run the following commands to search admin username in both files:

sudo cat /opt/couchdb/etc/local.ini | grep '^admin = '
sudo cat /opt/couchdb/etc/local.d/10-admins.ini | grep '^admin = '

You will get output like this:

admin = -pbkdf2-1a26024e8a7d41bb271f993f2a0230ce8724485f,0a7f4fc48a5c28fa6ea1525b63e6a2e1,10

Open a file in which you found admin username:

sudo nano /opt/couchdb/etc/local.d/10-admins.ini

Set a new password:

[admins]
admin = pwd123

Save and close a file and restart the CouchDB service:

sudo service couchdb restart

When CouchDB is restarted, the password will be salted and encrypted.

Leave a Comment

Cancel reply

Your email address will not be published.