Guide to Resetting Database Passwords
In routine database management, resetting a database password is a common and necessary task. Whether for security reasons, password forgetfulness, or other causes, knowing how to reset database passwords is crucial for database administrators. This document will detail how to reset passwords for MariaDB, PostgreSQL, and Redis databases. When using ServBay, note that different versions of databases have different configurations and paths.
Resetting MariaDB Password
MariaDB is a fork of MySQL, a popular relational database management system. The following steps will guide you on how to reset the password for MariaDB.
The example will use version MariaDB 10.11
.
Steps to Reset MariaDB Password
Stop MariaDB Service:
bashservbayctl stop mariadb 10.11
1Start MariaDB in Safe Mode:
bash/Applications/ServBay/package/mariadb/10.11/current/bin/mysqld_safe --skip-grant-tables --skip-networking &
1Log in to MariaDB:
bash/Applications/ServBay/package/mariadb/10.11/current/bin/mysql -u root
1Reset Password:
sqlFLUSH PRIVILEGES; ALTER USER 'root'@'localhost' IDENTIFIED BY 'new_password'; FLUSH PRIVILEGES;
1
2
3Exit MariaDB:
sqlexit;
1Stop MariaDB Safe Mode:
bashservbayctl stop mariadb 10.11
1Restart MariaDB Service:
bashservbayctl start mariadb 10.11
1
Resetting PostgreSQL Password
PostgreSQL is a powerful, open-source object-relational database system. The following steps will guide you on how to reset the password for PostgreSQL.
The example will use version PostgreSQL 16
.
Steps to Reset PostgreSQL Password
- Find PostgreSQL Admin Account
Open the ServBay management panel and go to Settings
-> Database Passwords
to find the PostgreSQL Account
.
Stop PostgreSQL Service:
bashservbayctl stop postgresql 16
1Back up
pg_hba.conf
File:bashcp /Applications/ServBay/db/postgresql/16/pg_hba.conf /Applications/ServBay/db/postgresql/16/pg_hba.conf.bak
1Edit
pg_hba.conf
File to Disable Password Authentication:bashsed -i '' 's/scram-sha-256/trust/g' /Applications/ServBay/db/postgresql/16/pg_hba.conf
1Start PostgreSQL:
bashservbayctl start postgresql 16
1Access
psql
Command Line:bashpsql -h /Applications/ServBay/tmp -U <user from step 1> postgres # Example: psql -h /Applications/ServBay/tmp -U servbay postgres
1
2Reset Password:
sqlALTER USER <user from step 1> WITH PASSWORD 'new_password'; -- Example: ALTER USER servbay WITH PASSWORD 'new_password';
1
2Exit
psql
:sql\q
1Stop PostgreSQL Service:
bashservbayctl stop postgresql 16
1Restore
pg_hba.conf
File:bashcp /Applications/ServBay/db/postgresql/16/pg_hba.conf.bak /Applications/ServBay/db/postgresql/16/pg_hba.conf
1Restart PostgreSQL Service:
bashservbayctl start postgresql 16
1
Resetting Redis Password
Redis is an open-source, in-memory data structure store used as a database, cache, and message broker. The following steps will guide you on how to reset the password for Redis.
Steps to Reset Redis Password
Open Redis Configuration File:
bashvim /Applications/ServBay/package/etc/redis/redis.conf
1Find and Modify the
requirepass
Configuration:plaintextrequirepass new_password
1Save and Exit Editor.
Restart Redis Service:
bashservbayctl restart redis -all
1
Summary
Resetting database passwords is an important task in database management. This document provides detailed instructions on how to reset passwords for MariaDB, PostgreSQL, and Redis databases. When using ServBay, be mindful that different versions of databases have different configurations and paths. By following these steps, you can ensure the security and accessibility of your databases. Whether for security reasons or due to forgotten passwords, mastering these skills will help you manage database systems more effectively.