Dmytro Shamenko
08/18/2025, 7:35 AM2025-08-18T07:31:20.273Z ERROR Unable to create SQL database. {"error": "pq: permission denied to create database", "logging-call-at": "/home/runner/work/docker-builds/docker-builds/temporal/tools/sql/handler.go:93"}
Which permissions my db user require?kapa.ai
08/18/2025, 7:35 AMpq: permission denied to create database indicates that the database user configured for Temporal does not have permission to create new databases. Airbyte’s Temporal component expects to be able to create the temporal and temporal_visibility databases if they do not already exist. Required permissions: - The user needs the CREATEDB privilege on the Postgres server if you want Temporal to create these databases automatically. - Alternatively, you can manually create the temporal and temporal_visibility databases and then grant all privileges on these databases to the Airbyte user. In this case, the user does not need CREATEDB, but must have full privileges on the databases. Example SQL commands: sql -- If you want to manually create the databases: CREATE DATABASE temporal; GRANT ALL PRIVILEGES ON DATABASE temporal TO airbyte; CREATE DATABASE temporal_visibility; GRANT ALL PRIVILEGES ON DATABASE temporal_visibility TO airbyte; This approach is confirmed as a solution in the Airbyte community and documentation: if the user cannot have CREATEDB rights, you must pre-create the databases and grant the necessary privileges to the Airbyte user. Otherwise, grant the user CREATEDB so Temporal can create them as needed [Forum Post: "Unable to create SQL database."](https://discuss.airbyte.io/t/1544) [Github Issue: External Postgres Database Setup Issues](https://github.com/airbytehq/airbyte/issues/49304). Summary: - Grant your user the CREATEDB privilege, or - Manually create the required databases and grant all privileges on them to the Airbyte user. Let me know if you need the exact SQL for granting CREATEDB!Dmytro Shamenko
08/18/2025, 7:37 AMresource "postgresql_role" "airbyte_role" {
name = "airbyte"
superuser = false
replication = false
create_database = true
create_role = false
login = true
inherit = true
connection_limit = -1
password = data.sops_file.secrets.data["airbyte_role_password"]
}
resource "postgresql_database" "airbyte_db" {
name = "airbyte"
owner = postgresql_role.airbyte_role.name
template = "template0"
encoding = "UTF8"
lc_collate = "en_US.UTF-8"
lc_ctype = "en_US.UTF-8"
connection_limit = -1
allow_connections = true
provisioner "local-exec" {
command = <<-EOF
psql -h "${module.aurora.cluster_endpoint}" \
-p 5432 \
-U "${local.master_username}" \
-d "airbyte" \
-c "REVOKE CREATE ON SCHEMA public FROM public;"
EOF
environment = {
PGPASSWORD = data.sops_file.secrets.data["master_password"]
}
}
}kapa.ai
08/18/2025, 7:37 AMkapa.ai
08/18/2025, 7:37 AMairbyte, temporal, and temporal_visibility databases (for example, via Terraform), you must ensure that the Airbyte user has all required privileges on each database and on the public schema within those databases. From the error and the Terraform snippet, a common issue is that the Airbyte user does not have sufficient privileges on the public schema, especially if you revoke CREATE from public (as your provisioner does). Airbyte (and Temporal) need to be able to create tables, indexes, and other objects in the schema. What you need to check: 1. Database Ownership and Privileges: - The Airbyte user should be the owner of the database or at least have ALL PRIVILEGES on the database. - The Airbyte user must have ALL PRIVILEGES on the public schema. 2. Schema Privileges: - If you revoke CREATE on the public schema from public, you must explicitly grant it to the Airbyte user: sql GRANT ALL ON SCHEMA public TO airbyte; 3. Error Example from Knowledge Sources: - Users have reported errors like permission denied for schema public when the Airbyte user does not have sufficient privileges on the schema, even if the database exists and is owned by the user. - See [Github Issue: Document grants required for external airbyte database](https://github.com/airbytehq/airbyte/issues/60244). Summary of required privileges: - On each database (airbyte, temporal, temporal_visibility): sql GRANT ALL PRIVILEGES ON DATABASE airbyte TO airbyte; GRANT ALL PRIVILEGES ON DATABASE temporal TO airbyte; GRANT ALL PRIVILEGES ON DATABASE temporal_visibility TO airbyte; - On the public schema in each database: sql GRANT ALL ON SCHEMA public TO airbyte; If you revoke CREATE from public, you must grant it to the Airbyte user, or Airbyte will not be able to create tables and you will see permission errors [Github Issue: Document grants required for external airbyte database](https://github.com/airbytehq/airbyte/issues/60244). Action: - Double-check that your Terraform or manual SQL grants ALL on the public schema to the Airbyte user in all three databases. - If you still see errors, check the logs for permission denied for schema public or similar messages. Let me know if you need the exact Terraform code for this grant!