ServBay Documentation: Managing Databases with Adminer
Overview
ServBay is a powerful local web development environment designed for macOS, integrating a variety of web servers, programming language runtimes, and database systems. To make it easy for developers to manage the built-in databases, ServBay comes pre-installed and configured with Adminer—a powerful yet lightweight database management tool. This document will guide you through connecting to and managing the databases included in ServBay using Adminer.
What is Adminer?
Adminer is a single-file database management tool written in PHP, supporting multiple database systems such as MySQL, MariaDB, PostgreSQL, SQLite, MongoDB, and more. Compared to some larger database management clients, Adminer offers the following notable advantages:
- Lightweight and Single-File Deployment: Adminer consists of just one PHP file, requiring no complex installation process, making it easy to deploy and use. ServBay has it integrated and ready to go out of the box.
- Multi-Database Support: With a unified interface, you can connect to and manage different types of databases, eliminating the need to install or learn multiple separate tools.
- Simple and Intuitive User Interface: Adminer provides a clear, easy-to-navigate UI, enabling even first-time users to get started quickly.
- Comprehensive Features: Supports virtually all common database operations, such as creating, modifying, and deleting databases, tables, indexes, users, executing SQL queries, importing/exporting data, and more.
For developers working with ServBay in their local environment, Adminer offers a convenient and efficient solution for database management.
Accessing Adminer
Once ServBay is running, Adminer is automatically launched and accessible through the built-in web server. You can access it by visiting ServBay’s default local domain followed by the Adminer filename:
https://servbay.host/adminer.php
Make sure the ServBay application is running, and both the relevant web server (such as Caddy or Nginx) and the database services you wish to connect to are started.
Connecting to Databases in ServBay
Adminer's login screen is very intuitive. You'll need to select the database type and provide the server address, username, password, and (for some database types) database name. ServBay generates default usernames and passwords for the built-in databases; you can find these in the "Database" tab of the ServBay app.
Connecting to MariaDB / MySQL
ServBay typically comes with MariaDB or MySQL by default. In Adminer, you usually select the "MySQL" database type to connect.
- Open your browser and go to the Adminer URL (
https://servbay.host/adminer.php
). - On the login screen, select
MySQL
in the System dropdown. - Enter the server connection details:
- Server: Enter
localhost
or use the Unix Socket path provided by ServBay:/Applications/ServBay/tmp/mysql.sock
. Socket connections are generally more efficient. - Username: Find the MariaDB/MySQL username in the ServBay app under "Database".
- Password: Find the MariaDB/MySQL password in the ServBay app under "Database".
- Database: (Optional) To connect directly to a specific database, enter its name here. Leaving it blank connects you to the server, and you can manage all databases after logging in.
- Server: Enter
- Click the
Login
button.
Connecting to PostgreSQL
ServBay also supports PostgreSQL. In Adminer, you’ll need to select the "PostgreSQL" system type.
- Open your browser and go to the Adminer URL (
https://servbay.host/adminer.php
). - On the login screen, select
PostgreSQL
in the System dropdown. - Enter the connection details:
- Server: Enter
/Applications/ServBay/tmp
. - Username: Find the PostgreSQL username in the ServBay app under "Database".
- Password: Find the PostgreSQL password in the ServBay app under "Database".
- Database: Enter the name of the database you wish to connect to (e.g., the default
postgres
database or any you have created).
- Server: Enter
- Click the
Login
button.
Connecting to SQLite 3
ServBay supports SQLite 3 databases. Since SQLite is file-based, you need to specify the database file path upon connecting.
- Open your browser and go to the Adminer URL (
https://servbay.host/adminer.php
). - On the login screen, select
SQLite 3
in the System dropdown. - Enter the database file path:
- Database file: Enter the full path to your SQLite database file. It’s recommended to store your SQLite files in ServBay’s data directory, such as
/Applications/ServBay/db/sqlite/your_database_name.sqlite
. - If the specified file does not exist, Adminer will prompt you to create the new database file.
- Database file: Enter the full path to your SQLite database file. It’s recommended to store your SQLite files in ServBay’s data directory, such as
- Click the
Login
button.
Performing Common Database Operations
Once logged into the database server or a specific database, you can use Adminer's interface to perform a variety of database management tasks. The interface and features may vary slightly by database type, but the basic workflow remains similar.
Creating a Database
(Applies to MariaDB/MySQL, PostgreSQL)
- Log in to the database server (without specifying a particular database).
- In the left sidebar or main interface, locate the
Create database
or similar option. - Enter the name of the new database.
- Select the character set and collation (if needed).
- Click
Save
orCreate
.
(For SQLite 3, you create a database by specifying a new file path when logging in.)
Managing Tables and Data
- Select a database (if not specified at login).
- On the database overview page, find the
Create table
option. - Enter the table name and define its fields (columns), including name, data type, length, whether NULL is allowed, default value, indexes (primary key, unique, regular), etc.
- Click
Save
to create the table. - After creation, select the table from the left sidebar or overview page.
- Perform data operations:
Insert
: Add new rows of data.Select
: View, search, sort, and filter existing data.Update
: Modify existing rows.Delete
: Remove rows.- Use
SQL command
to run more complex queries and operations.
Executing SQL Commands
Adminer provides an SQL command input interface where you can directly enter and execute SQL statements for flexible database management and data queries.
- Select the database you want to run commands on.
- Click the
SQL command
option. - Enter your SQL statements in the text area.
- Click the
Execute
button.
Importing and Exporting Data
Adminer supports exporting database structures and data as SQL files or other formats (such as CSV), as well as importing data from these files. This is useful for data migration, backups, or sharing data with others.
- Select the database or table you wish to import/export.
- Find the
Export
orImport
option. - Follow the prompts to choose format, options, and execute the operation.
Deleting a Database
(Applies to MariaDB/MySQL, PostgreSQL)
- Log in to the database server (without specifying a particular database).
- In the database list, select the database you want to delete.
- Click the
Delete
option and confirm your choice.
Note: This operation is irreversible and will permanently delete the database and all its data.
(For SQLite 3, deleting a database simply means deleting its .sqlite
file manually from the file system.)
Notes & Considerations
- Credential Security: Keep the database usernames and passwords obtained from your ServBay settings safe and secure. Do not share them.
- ServBay Status: Adminer is accessible through ServBay's internal web server, and database services must be running for connections to work. If you cannot access Adminer or the databases, check that the ServBay application and relevant packages (Caddy/Nginx, MariaDB/MySQL, PostgreSQL, etc.) are up and running.
- SQLite File Path: Make sure the SQLite database file path is in a location where the ServBay user has read/write permissions. It’s recommended to use ServBay’s data directory at
/Applications/ServBay/db/sqlite/
. - Performance: While Adminer is lightweight and convenient, for very large databases or advanced management tasks, dedicated desktop client tools (like TablePlus, DBeaver, pgAdmin, etc.) may offer more features or better performance.
Frequently Asked Questions (FAQ)
Q: What should I do if I can't access https://servbay.host/adminer.php
?
A: Make sure the ServBay application is running and that ServBay’s web server (usually Caddy or Nginx) has started. Also, check if your browser allows access to https://servbay.host
.
Q: What if I forgot the database username or password? Where can I find them?
A: You can find the default-generated usernames and passwords for each database in the "Database" tab of the ServBay application interface.
Q: When connecting to PostgreSQL, what are the server address and port?
A: The server address is usually localhost
, and the default port is 5432
. You can confirm the PostgreSQL listening address and port in ServBay’s settings. For Unix Domain Socket connections, enter /Applications/ServBay/tmp
(no .sock
suffix needed for PostgreSQL).
Q: For MariaDB/MySQL, what's the difference between the server address and socket path?
A: localhost
typically uses a TCP/IP connection (default port 3306), while /Applications/ServBay/tmp/mysql.sock
connects via Unix Domain Socket. On local environments, socket connections are usually a bit faster and more secure, but you can use either depending on your needs.
Q: Can I manage databases not built into ServBay using Adminer?
A: Adminer itself supports many database types. If you have separately installed databases (such as standalone MongoDB instances or remote databases), you can theoretically connect to them using the Adminer file provided by ServBay, as long as they are network-accessible and you have the correct connection information. However, Adminer’s main value in ServBay lies in providing convenient management for the built-in databases.
Conclusion
Adminer is a highly convenient database management tool provided by ServBay. Thanks to its single-file, lightweight nature and multi-database support, it greatly simplifies managing MariaDB/MySQL, PostgreSQL, and SQLite databases in your local development environment. With this guide, you should be able to easily connect to ServBay’s databases and use Adminer for daily database management and data operations tasks.