Configure External PostgreSQL

By default, Bytebase bundles an embedded PostgreSQL instance for storing its own metadata. The metadata is stored under the --data directory.

For production setup, you should pass PG_URL environment variable to store these metadata in an external PostgreSQL database.

Prerequisites

  1. PostgreSQL 14 or above.
  2. All privileges on the database object including:
    • SELECT
    • INSERT
    • UPDATE
    • DELETE
    • TRUNCATE
    • REFERENCES
    • TRIGGER
    • CREATE
    • CONNECT
    • TEMPORARY
    • EXECUTE
    • USAGE
  3. The database should use UTF-8 for encoding. UTF-8 encoding is mandatory across the entire system.
  4. For Cloud RDS, ensure that the user either owns the schema (public) and database, or has the necessary privileges to access them.
    • ALTER DATABASE dbname OWNER TO bytebase;
    • ALTER SCHEMA public OWNER TO bytebase;

Connection string format for PG_URL

Supported format:

postgresql://<<user>>:<<secret>>@<<host>>:<<port>>/<<dbname>>

Example:

postgresql://bytebase:z*[email protected]:5432/meta

  • user must be specified.
  • dbname must be specified and must be created in advance. The connecting user must have all the database privileges mentioned above.
  • host. If you run Bytebase inside Docker and want to connect the pg instance on the same host, then you need to use host.docker.internal.

Docker Sample

This bash script demonstrates how to add an external PostgreSQL database as the metadata store when running the bytebase container.

docker run--rm --init \
  # Use `host.docker.internal` as the host if you connect the pg instance on the same host.
  -e PG_URL=postgresql://user:secret@host:port/dbname
  --name bytebase \
  --publish 8080:8080 \
  --volume ~/.bytebase/data:/var/opt/bytebase \
  bytebase/bytebase:2.21.0
Edit this page on GitHub

Subscribe toย Newsletter

By subscribing, you agree with Bytebase's Terms of Service and Privacy Policy.