Obtain Root Credentials and Connection Information for ServBay Databases
For developers using ServBay to build a local web development environment, it is crucial to understand how to access and use root credentials and connection details for your databases. This information is essential for connecting with database clients, configuring applications, working with ORMs, or using command-line tools.
This article provides a detailed guide on locating and using root credentials and various connection details (including username, password, host, port, and socket path) for the MySQL, MariaDB, PostgreSQL, and Redis databases bundled with ServBay.
Prerequisites
Before proceeding, please ensure that:
- ServBay has been successfully installed and is running.
- The required database packages (such as MySQL, MariaDB, PostgreSQL, Redis) are installed and started within ServBay.
Finding Database Connection Information in the ServBay Panel
ServBay offers a user-friendly graphical interface to manage and view database connection info, especially for databases like MySQL, MariaDB, and PostgreSQL, which require user authentication.
To obtain root credentials and connection information for these databases, follow these steps:
- Open the ServBay control panel. You can find and launch the ServBay icon in the Applications folder on your Mac.
- In the left sidebar, locate and click on the
Databases
option. - In the list of databases, select the database type you want to view, e.g.,
MySQL
. - If you have multiple MySQL versions installed, select the specific version you are using, such as
MySQL 8.4
. - On the version details page on the right, you will see the Root username and password for that database version.
- Click the
Eye
icon next to the password field to reveal the root user's actual password.
On this page, you'll also see the default connection details for each database version, such as host address and port.
Note: Even if some older documentation or installation processes mention a default password, the password displayed in the ServBay control panel is always the current valid one. Always rely on the information shown in the control panel.
For PostgreSQL, the default superuser (equivalent to "root") is typically your current system username at the time of ServBay installation. When checking in the panel, it will display this username and the corresponding password.
By default, Redis does not have a password. If a password is set in the Redis configuration, you can view its connection details under the Redis package settings in ServBay.
Default Database Connection Details
Below are the typical default connection settings for each database in ServBay:
MySQL Default Connection Details
- Username: Obtain from the ServBay control panel, usually
root
by default. - Password: Obtain from the ServBay control panel.
- Host:
localhost
or127.0.0.1
(for TCP/IP connections). - Port:
3306
(default port). - Socket:
/Applications/ServBay/tmp/mysql-<version>.sock
(replace<version>
with your MySQL version, e.g.8.4
). ServBay may also provide a symlink to the currently active version, such as/Applications/ServBay/tmp/mysql.sock
.
MariaDB Default Connection Details
- Username: Obtain from the ServBay control panel, usually
root
by default. - Password: Obtain from the ServBay control panel.
- Host:
localhost
or127.0.0.1
(for TCP/IP connections). - Port:
3306
(default port, shared with MySQL). - Socket:
/Applications/ServBay/tmp/mariadb-<version>.sock
(replace<version>
with your MariaDB version). ServBay may also provide a symlink like/Applications/ServBay/tmp/mysql.sock
for greater compatibility.
PostgreSQL Default Connection Details
- Username: Obtain from the ServBay control panel, typically your current system username.
- Password: Obtain from the ServBay control panel.
- Host:
localhost
or127.0.0.1
(for TCP/IP connections). - Port:
5432
(default port). - Socket:
/Applications/ServBay/tmp/.s.PGSQL.5432
(the socket file for default port5432
).
Redis Default Connection Details
- Host:
127.0.0.1
(for TCP/IP connections). - Port:
6379
(default port). - Password: No password by default. If a password is set in Redis’s configuration, it is required for connection.
MongoDB Connection Details
MongoDB typically does not require a global “root” user and password to start the service. By default, authentication may not be enabled after installation. For secure connections, you usually need to connect using the MongoDB shell or a client and manually create a user and assign roles (such as root
). ServBay’s MongoDB package has the following default connection info:
- Host:
127.0.0.1
- Port:
27017
(default port). - Authentication: Disabled by default. For authentication, create a user as per the MongoDB documentation.
Connecting to Databases via Socket
When your application or client runs on the same machine (your local environment), using a socket connection is usually more efficient and secure than TCP/IP, as it bypasses the network stack. Socket connections occur via the file system path.
MySQL/MariaDB Socket Connections
- Common socket file paths:
/Applications/ServBay/tmp/mysql.sock
: A symlink provided by ServBay, pointing to the active MySQL/MariaDB version's socket./Applications/ServBay/tmp/mysql-<version>.sock
(MySQL versions) or/Applications/ServBay/tmp/mariadb-<version>.sock
(MariaDB versions): Directly points to a specific version's socket file. This format is recommended for clarity.
Connection examples (using the mysql
CLI):
# Using the symlink path (if present and correctly linked)
mysql -u root -p -S /Applications/ServBay/tmp/mysql.sock
# Using the specific version socket path (recommended; replace <version> with actual version, e.g., 8.4)
mysql -u root -p -S /Applications/ServBay/tmp/mysql-8.4.sock
2
3
4
5
After running the command, you will be prompted for the root password.
PostgreSQL Socket Connections
Socket connections for PostgreSQL differ slightly from MySQL/MariaDB. The psql
CLI uses the -h
argument to specify the directory where the socket file exists, not the full path to the socket file itself. The socket file is named .s.PGSQL.<port>
.
- Socket file path:
/Applications/ServBay/tmp/.s.PGSQL.5432
(for default port 5432). The directory is/Applications/ServBay/tmp
.
Connection example (using the psql
CLI):
# Replace your_system_username with your system username
psql -U your_system_username -h /Applications/ServBay/tmp -d your_database
2
After running the command, you will be prompted for the password. -d your_database
specifies the target database. If not provided, psql
may try to connect to a database that has the same name as your username, or to the default postgres
database.
Redis Socket Connections
Currently, the Redis package in ServBay mainly supports TCP/IP connections. Socket connections are not yet supported for Redis.
Database Connection Command Examples
Below are examples of command-line connection commands for built-in ServBay databases. Replace the usernames, passwords (enter when prompted), and database names as needed for your environment.
Connecting to MySQL
Using TCP/IP:
bash# Connect to localhost on default port 3306 as root mysql -u root -p -h localhost -P 3306
1
2After entering the command and pressing Enter, you will be prompted for the root password.
Using socket:
bash# Using the symlink socket path mysql -u root -p -S /Applications/ServBay/tmp/mysql.sock # Or using the specific version socket path (recommended) # Replace <version> with your MySQL version, such as 8.4 mysql -u root -p -S /Applications/ServBay/tmp/mysql-8.4.sock
1
2
3
4
5
6After entering the command, press Enter and enter the root password.
Connecting to MariaDB
The command for MariaDB is nearly identical to MySQL, since MariaDB is highly compatible by design.
Using TCP/IP:
bash# Connect to localhost on default port 3306 as root mysql -u root -p -h localhost -P 3306
1
2Enter the root password when prompted.
Using socket:
bash# Using the symlink socket path (could point to MariaDB socket) mysql -u root -p -S /Applications/ServBay/tmp/mysql.sock # Or using the specific MariaDB version socket path (recommended) # Replace <version> with your MariaDB version mysql -u root -p -S /Applications/ServBay/tmp/mariadb-<version>.sock
1
2
3
4
5
6Enter the root password when prompted.
Connecting to PostgreSQL
Using TCP/IP:
bash# Replace your_system_username with your system username # Replace your_database with your target database name, such as postgres psql -U your_system_username -h localhost -d your_database -p 5432
1
2
3Enter your password when prompted.
Using socket:
bash# Replace your_system_username with your system username # Replace your_database with your target database name # Note: supply the directory, /Applications/ServBay/tmp, with -h psql -U your_system_username -h /Applications/ServBay/tmp -d your_database
1
2
3
4Enter your password when prompted.
Connecting to Redis
Redis is typically connected via TCP/IP.
Using TCP/IP:
bash# Connect to localhost on default port 6379 redis-cli -h 127.0.0.1 -p 6379 # If Redis is password-protected, add the -a parameter # redis-cli -h 127.0.0.1 -p 6379 -a your_redis_password
1
2
3
4
5Using socket: Socket connections are not currently supported for ServBay's Redis package.
Use Cases
Accessing database connection information is fundamental for local development and database management in the following scenarios:
- Database management tools: Use graphical database clients (e.g., TablePlus, DBeaver, phpMyAdmin, pgAdmin, etc.) to connect to ServBay databases for viewing, editing, importing/exporting data, etc.
- Application configuration: Configure database connection parameters in your web application's config files or environment variables (with PHP, Node.js, Python, Go, Java, etc.).
- ORM configuration: Set up your Object-Relational Mapper (e.g., Laravel Eloquent, Django ORM, SQLAlchemy, TypeORM) to connect to the database.
- Command-line operations: Use standard CLI clients for SQL, user management, backup, restoration, and more.
Notes
- Security: Default passwords are for local development convenience. While ServBay is mainly used for local work, for best security practice, update the root password via the ServBay panel or your database’s management tool—especially if your development environment is accessible over a network.
- Changing passwords: ServBay’s control panel usually allows you to update root passwords for MySQL, MariaDB, and PostgreSQL. After changing a password, make sure to update connection settings in all your applications and tools accordingly.
- Backup your credentials: It's highly recommended to record your updated root passwords and connection details and keep them securely.
Frequently Asked Questions (FAQ)
Q: What if I forget the database root password?
A: You can view the current root password on the
Databases
page in the ServBay control panel (click the Eye icon to reveal it). If you cannot access the panel (e.g., if the database isn’t running), ServBay also provides a password reset function for MySQL, MariaDB, and PostgreSQL—usually found in the settings for that database version.Q: Can I change the root password?
A: Yes, and it’s strongly recommended to change the default password. You can do this through the settings for each database version in the ServBay control panel. Don’t forget to update all application and client configurations that use this password after changing it.
Q: Why isn’t PostgreSQL’s default username 'root'?
A: PostgreSQL’s permission system is different from MySQL/MariaDB. Its superuser (with highest privileges) is typically the user created during cluster initialization, which under ServBay’s default configuration is your system username. Once connected, you can create other database users and assign permissions.
Q: Why can’t I connect to the database using a socket?
A: First, verify that the database service is running. For MySQL/MariaDB, check that your socket file path is correct (the version-specific path is recommended). For PostgreSQL, ensure you use the
-h
argument in yourpsql
command and provide the socket directory (/Applications/ServBay/tmp
), not the full socket file path.
Summary
Having access to connection details for the built-in databases (MySQL, MariaDB, PostgreSQL, Redis) is a key step for local web development and database management with ServBay. With the ServBay control panel, you can easily find the root usernames, passwords, and all relevant connection information for MySQL, MariaDB, and PostgreSQL. Redis, by default, has no password and supports standard TCP/IP connections. This guide has explained how to connect to databases using both TCP/IP and socket connections, provided practical command-line examples, outlined typical use cases, important notes, and FAQs. We hope this helps you work more efficiently with ServBay in your development workflow.