Skip to content

Databases

PortBay can provision, configure, and supervise local database instances on your machine. Each instance gets an isolated data directory, an engine-specific config file, and a dedicated port — all managed through Process Compose, the same supervision layer that runs your dev servers. Supported engines are MySQL, MariaDB, PostgreSQL, Redis, MongoDB, and Memcached. Instances can be linked to projects, which injects connection env vars (DATABASE_URL, DB_*) into the linked project's process on every start.

PortBay databases

Quickstart

Prerequisites: The engine binary must be installed via Homebrew. If it isn't, the Add Database wizard shows the install hint.

  1. Open the Databases section from the sidebar.
  2. Click Add Database, pick an engine, give the instance a name, and optionally specify a port (PortBay auto-allocates one if left blank).
  3. Click Create. PortBay initialises the data directory (this runs mysqld --initialize-insecure, initdb, etc. in the background — expect up to 30–120 seconds for MySQL and PostgreSQL).
  4. The instance appears in the sidebar. Click Start in the detail panel to bring it up.
  5. Copy the Connection URL from the Connection section and paste it into your app or .env.
mysql://root@127.0.0.1:3306/
postgresql://postgres@127.0.0.1:5432/postgres
redis://127.0.0.1:6379
mongodb://127.0.0.1:27017
memcached://127.0.0.1:11211

Port numbers shown above are the defaults; the actual port for your instance is shown in the Connection panel and may differ if the default was already in use.

How-To

Create an instance from an engine

  1. Click Add Database.
  2. Select an engine. If it shows as not installed, run the displayed brew install … command and reopen the wizard.
  3. Enter a name (slugified into the instance ID) and, optionally, a custom port.
  4. Enable Start automatically when PortBay launches if you want the daemon to come up on every app start.
  5. Click Create. The wizard spins while provisioning runs.

Start, stop, and restart

Use the toolbar buttons in the instance detail panel:

  • Start — available when the instance is stopped or errored. Triggers a reconciler tick then sends start to Process Compose.
  • Stop — available when the instance is running or starting.
  • Restart — available only when running; reconciles then sends restart.

Status updates are live (polled from Process Compose).

Set auto-start

Check or uncheck Start automatically when PortBay launches at the bottom of the detail panel. The setting is persisted immediately and triggers a reconciler tick so the Process Compose YAML reflects the change.

Linking injects connection env vars into the project's process on every PortBay-managed start.

  1. Select an instance.
  2. In the Linked projects card, click Link project and choose a project from the picker.
  3. On the project's next start, PortBay injects:
VariableValue
DATABASE_URLThe instance's connection URL
DB_CONNECTIONEngine id (mysql, mariadb, postgres, redis, mongo, memcached)
DB_HOST127.0.0.1
DB_PORTInstance port
DB_USERNAMEDefault account (root for MySQL/MariaDB, postgres for PostgreSQL; empty for Redis, MongoDB, Memcached)
DB_PASSWORDEmpty string

The per-project env block always overrides injected vars, so you can still override individual values in the project settings without unlinking.

To unlink, click the × next to the project name in the Linked projects card.

Open in a DB client

Click Client in the toolbar. PortBay resolves the engine's CLI binary from the Homebrew opt directory and opens it in Terminal.app, pre-configured for the instance's port:

EngineCommand format
MySQL / MariaDBmysql -u root -h 127.0.0.1 -P <port>
PostgreSQLpsql -U postgres -h 127.0.0.1 -p <port> postgres
MongoDBmongosh mongodb://127.0.0.1:<port>
Redisredis-cli -h 127.0.0.1 -p <port>
Memcachednc 127.0.0.1 <port>

The button is disabled when no client binary is found for the engine (clientAvailable: false).

Reveal the data folder

Click Reveal data folder in the toolbar or Open Data Folder in the footer. Opens the instance's data directory in Finder. The data directory path is also shown and copyable in the Paths / Storage card.

Remove an instance

Click Remove in the toolbar. A confirmation dialog presents two choices:

  • Deregister only — stops the daemon, drops the instance from the registry and from any linked projects, leaves the data directory on disk. You can re-add the instance later and it will reuse the existing data.
  • Delete data + deregister — does the above and also deletes the instance's data directory. Irreversible.

If the binary is no longer present when you try to start (binaryAvailable: false), an error note appears under the instance name. Reinstall the engine via Homebrew to restore normal operation.

ProjectDbConnection vs. DatabaseInstanceView

PortBay surfaces two distinct database concepts:

DatabaseInstanceViewProjectDbConnection
What it isA PortBay-provisioned, supervised server instanceA DB connection parsed from a project's on-disk .env
Managed byPortBay (lifecycle, port allocation, data dir)The project itself
Where it appearsDatabases sectionProject detail → DB Connections tab
Auth env injectionYes, via instance linkingNo — read-only display

A project can have both: a DatabaseInstanceView linked to it (PortBay's managed instance) and separate ProjectDbConnection entries discovered from its .env file (e.g. a remote staging DB or a Docker-managed instance). The two do not interfere with each other.

Reference

Supported engines

EngineIDDefault portHomebrew installCLI client
MySQLmysql3306brew install mysqlmysql
MariaDBmariadb3306brew install mariadbmariadb / mysql
PostgreSQLpostgres5432brew install postgresql@16psql
Redisredis6379brew install redisredis-cli
MongoDBmongo27017brew install mongodb-communitymongosh
Memcachedmemcached11211brew install memcachednone (uses nc)

MySQL and MariaDB share the same default port (3306). If both are registered, PortBay auto-allocates a different port for whichever is added second.

DatabaseInstanceView fields

FieldTypeDescription
idstringSlug derived from the instance name. Used as the Process Compose process name (db-<id>).
namestringUser-facing display name.
engineDatabaseEngineIdEngine id string (see table above).
engineLabelstringHuman-readable engine name (e.g. "PostgreSQL").
versionstringVersion detected from the daemon binary at create time (e.g. "16.2").
portnumberListening port allocated at create time.
statusInstanceStatusCurrent status (see below).
autoStartbooleanWhether PortBay starts this instance at launch.
dataDirstringAbsolute path to the instance's data directory.
configPathstring | nullAbsolute path to the generated config file, or null for engines launched purely with CLI flags.
socketPathstring | nullAbsolute path to the Unix socket, or null for engines that don't use one (PostgreSQL uses a directory, not a single socket file; Memcached has no socket).
connectionUrlstringReady-to-use connection URL for frameworks.
accountstringDefault superuser account (root, postgres, or empty).
linkedProjectsstring[]IDs of projects this instance is linked to.
binaryAvailablebooleanFalse when the daemon binary can no longer be found on the machine.
provisionedbooleanTrue when the data directory has been initialised for this engine.

Instance statuses

StatusMeaning
runningDaemon is up and Process Compose reports it as running/ready.
stoppedProcess is not present or not running in Process Compose.
startingProcess Compose reports launching/starting state.
erroredProcess Compose reports an error or failed state.

Storage layout

All database data lives inside PortBay's app-data directory:

~/Library/Application Support/PortBay/databases/
  <instance-id>/
    data/          ← engine data directory
    my.cnf         ← MySQL / MariaDB config
    redis.conf     ← Redis config
    mongod.conf    ← MongoDB config (YAML)
    mysql.sock     ← MySQL / MariaDB unix socket
    redis.sock     ← Redis unix socket
    mongod.sock    ← MongoDB unix socket

PostgreSQL keeps its config inside the data directory (data/postgresql.conf, generated by initdb). PostgreSQL sockets live in <instance-id>/ rather than at a named socket file path.

Memcached has no config file and no socket; it is launched entirely with CLI flags.

Config file paths by engine

EngineConfig location
MySQL<instance-id>/my.cnf
MariaDB<instance-id>/my.cnf
PostgreSQL<instance-id>/data/postgresql.conf
Redis<instance-id>/redis.conf
MongoDB<instance-id>/mongod.conf
MemcachedNone

PortBay is pre-MVP software. Use the docs as an operating guide, not a stability guarantee.