Guide to Resetting Database Passwords in ServBay
When developing web applications using the ServBay local development environment, managing databases such as MySQL, MariaDB, PostgreSQL, and Redis is one of the core tasks. Occasionally, for security purposes, forgotten credentials, or other reasons, you may need to reset database user passwords. This article provides a detailed, secure, and efficient guide to resetting passwords for these popular databases in ServBay, covering both graphical and command-line methods.
Please note: the configuration and paths for different versions of database packages in ServBay may vary slightly. Always refer to the actual version you are using when performing these operations.
Resetting MySQL/MariaDB root
Password
TIP
Resetting the root
user password for MySQL and MariaDB databases involves essentially the same steps. This section uses MariaDB as an example.
MySQL and MariaDB are widely used relational database management systems and form important components of ServBay. This section will provide a step-by-step guide on how to reset the root
password for MySQL and MariaDB within ServBay.
The demonstration below uses the integrated MariaDB 11.3
version from ServBay as an example.
Method 1: Reset MariaDB root
Password via ServBay GUI
ServBay offers a user-friendly graphical interface to quickly reset the root
password for your databases.
- Launch the ServBay application.
- Expand the
Databases
section in the left sidebar, selectMariaDB
, then pick the specific version you want to reset the password for (e.g.,MariaDB 11.3
). - On the details page for the selected package (on the right), locate the
Password
input field. - Click the lock icon next to the
Password
field. - A prompt will appear to confirm resetting the
root
password. ClickConfirm
. - The
root
password will be reset to ServBay’s default:ServBay.dev
.
Method 2: Reset MariaDB root
Password from the Command Line
For more advanced users, or cases when you need to automate the process, the MariaDB root password can also be reset via the command line. This method usually involves launching the database in a mode that skips privilege checks.
The steps below use MariaDB 11.3
as an example; please adjust paths and version numbers to match your installation.
Stop the MariaDB Service: Use ServBay’s control tool to stop the MariaDB service.
bashservbayctl stop mariadb 11.3
1Replace
mariadb 11.3
with the correct version identifier for your MariaDB instance.Start MariaDB in Safe Mode: Launch MariaDB with grant tables and networking disabled to bypass authentication.
bash/Applications/ServBay/package/mariadb/11.3/current/bin/mysqld_safe --skip-grant-tables --skip-networking &
1/Applications/ServBay/package/mariadb/11.3/current/bin/mysqld_safe
is the MariaDB executable path within ServBay.--skip-grant-tables
allows login without a password and full privileges;--skip-networking
prevents remote connections for safety. The&
runs the process in the background.Log in to MariaDB: Use the
mysql
client to log in asroot
—no password is required in safe mode.bash/Applications/ServBay/package/mariadb/11.3/current/bin/mysql -u root
1The given path points to the MariaDB client executable.
Reset the Password: Inside the MariaDB prompt, update the root password using SQL commands.
sqlFLUSH PRIVILEGES; -- Refresh privileges to ensure ALTER USER takes effect ALTER USER 'root'@'localhost' IDENTIFIED BY 'new_password'; -- Replace 'new_password' with your new password FLUSH PRIVILEGES; -- Refresh again after changes
1
2
3Replace
'new_password'
with a strong password of your choice. Do not use the defaultServBay.dev
unless strictly for temporary use.Exit MariaDB: After resetting the password, exit the
mysql
client.sqlexit;
1Stop the Safe Mode MariaDB Process: Stop the safe-mode MariaDB instance. Preferably, use
servbayctl stop
, or manually kill themysqld_safe
background process if necessary.bashservbayctl stop mariadb 11.3
1If
servbayctl stop
doesn’t work for the safe-mode process (started withmysqld_safe &
), useps aux | grep mysqld_safe
to find the process ID, then terminate it withkill <PID>
.Restart MariaDB Service: Start MariaDB again in normal mode. The new password is now active.
bashservbayctl start mariadb 11.3
1
Resetting PostgreSQL Passwords
PostgreSQL is a robust, highly popular open-source object-relational database system. The steps below explain how to reset user passwords for PostgreSQL in ServBay, typically for the default admin user created by ServBay.
The example will use the integrated PostgreSQL 16
from ServBay.
PostgreSQL Password Reset Workflow
Resetting a PostgreSQL password typically requires temporarily modifying its authentication config file pg_hba.conf
to allow passwordless local connections, then executing SQL to set a new password.
Locate the PostgreSQL Admin Account: Determine which PostgreSQL username you need to reset. You can find this user in ServBay’s GUI:
Open ServBay’s control panel, navigate toDatabases
→PostgreSQL
, select your version (e.g.,PostgreSQL 16
). On the right details panel, note the administrator’s username in theAccount
section—usually something likeservbay
.Stop PostgreSQL Service: Stop the PostgreSQL service using ServBay’s control command.
bashservbayctl stop postgresql 16
1Replace
postgresql 16
with your actual PostgreSQL version identifier.Backup
pg_hba.conf
: Thepg_hba.conf
file controls PostgreSQL client authentication. Always back it up before editing.bashcp /Applications/ServBay/db/postgresql/16/pg_hba.conf /Applications/ServBay/db/postgresql/16/pg_hba.conf.bak
1Adjust the path according to your ServBay installation and PostgreSQL version.
Edit
pg_hba.conf
to Temporarily Allow Trust Authentication: Edit the file and change local authentication from password-based (likescram-sha-256
ormd5
) totrust
, so you can connect without a password.bashsed -i '' 's/scram-sha-256/trust/g' /Applications/ServBay/db/postgresql/16/pg_hba.conf
1This
sed
command (for macOS) replaces allscram-sha-256
references withtrust
in the config file. If your file usesmd5
or another method, adjust the replacement target (e.g.,s/md5/trust/g
). The-i ''
flag edits the file in place.Start PostgreSQL: Restart the service for the config change to take effect.
bashservbayctl start postgresql 16
1Access the
psql
Command-Line: Use thepsql
client to connect to PostgreSQL. With trust authentication enabled, you won’t need a password.bashpsql -h /Applications/ServBay/tmp -U <username from step 1> postgres # Example: psql -h /Applications/ServBay/tmp -U servbay postgres
1
2Substitute
<username from step 1>
with the actual admin username. The-h /Applications/ServBay/tmp
connects via the ServBay-created Unix socket;-U <user>
specifies the user, andpostgres
is the default database.Reset the Password: At the
psql
prompt, set a new password for the user.sqlALTER USER <username from step 1> WITH PASSWORD 'new_password'; -- Example: ALTER USER servbay WITH PASSWORD 'new_password';
1
2Replace
<username from step 1>
with your account’s actual username, and'new_password'
with a strong password.Exit
psql
: When finished, quit thepsql
shell.sql\q
1Stop PostgreSQL Service: Stop the service so you can restore the original authentication config.
bashservbayctl stop postgresql 16
1Restore the Original
pg_hba.conf
: Copy back the backup file to restore password authentication for security.bashcp /Applications/ServBay/db/postgresql/16/pg_hba.conf.bak /Applications/ServBay/db/postgresql/16/pg_hba.conf
1Restart PostgreSQL Service: Start PostgreSQL again in password authentication mode.
bashservbayctl start postgresql 16
1You can now connect using your newly set password.
Resetting Redis Password
Redis is a high-performance open-source in-memory data store, often used for databases, caching, and messaging. Here’s how to reset the Redis password in ServBay.
Method 1: Reset Redis Password via the ServBay GUI
ServBay provides an intuitive way to manage Redis passwords through its interface.
- Open the ServBay application.
- In the left sidebar, expand
Databases
, selectNoSQL
, and then selectRedis
. - On the Redis details page (right side), find the
Password
input field. - Enter your new desired password in the field. (If no password was set before, the field may be blank.)
- Click the
Save
button next to the field. - ServBay will automatically restart Redis to apply your new settings.
Method 2: Edit redis.conf
Directly to Reset Redis Password
You can also reset the Redis password by modifying the redis.conf
configuration file.
Open the Redis Config File: Use a text editor to open the Redis config file in ServBay. It is usually found in ServBay’s config directory.
bashvim /Applications/ServBay/package/etc/redis/redis.conf
1You can use
vim
,nano
, or your preferred editor. Modify the path as needed to match your installation.Find and Edit the
requirepass
Directive: Inredis.conf
, look for the line that starts withrequirepass
. If it is commented out with a#
, remove the#
. Change the value to your desired new password.plaintextrequirepass your_new_strong_password
1Replace
your_new_strong_password
with a strong password of your choice.Save and Exit the Editor: Save your changes to the
redis.conf
file.Restart Redis Service: Use ServBay’s control tool to restart Redis so your changes take effect.
bashservbayctl restart redis -all
1The
restart redis -all
command restarts all Redis instances managed by ServBay.
Summary
Resetting database passwords is a vital aspect of database management. With this comprehensive guide, you now understand how to reset passwords for MySQL/MariaDB, PostgreSQL, and Redis in the ServBay local development environment. Whether you choose the ServBay GUI or the command-line approach, following these steps will help you quickly regain access after a forgotten password or enhance your system’s security. Always store your new passwords securely and use strong, unique passwords to keep your local development environment and data protected.