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.
Postgres version
PostgreSQL 14 or above.
Connection string format for PG_URL
Supported format:
postgresql://<<user>>:<<secret>>@<<host>>:<<port>>/<<database>>
Example:
postgresql://bytebase:z*3kd2@example.com:5432/meta
Database
The connecting database
must be created in advance. The database should use UTF-8 for encoding. UTF-8 encoding is mandatory across the entire system.
User
The connecting user
must have all the following database privileges:
- SELECT
- INSERT
- UPDATE
- DELETE
- TRUNCATE
- REFERENCES
- TRIGGER
- CREATE
- CONNECT
- TEMPORARY
- EXECUTE
- USAGE
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 example
This bash script demonstrates how to add an external PostgreSQL database as the metadata store when running the bytebase container.
Troubleshoot
Cannot new server ERROR: syntax error at or near xxx
Make sure that the connecting user is either superuser or is the owner of the connecting database. See User and GitHub Issue.