<@U04S8PLJWMT> I have setup the external database ...
# ask-ai
r
@kapa.ai I have setup the external database now I am getting an error ERROR: permission denied for schema public Position: 50 at org.jooq_3.19.18.POSTGRES.debug(Unknown Source) at org.jooq.impl.Tools.translate(Tools.java:3621) at org.jooq.impl.Tools.translate(Tools.java:3609) at org.jooq.impl.DefaultExecuteContext.sqlException(DefaultExecuteContext.java:827) at org.jooq.impl.AbstractQuery.execute(AbstractQuery.java:362) at org.jooq.impl.DefaultDSLContext.execute(DefaultDSLContext.java:1110) at io.airbyte.db.init.DatabaseInitializer$DefaultImpls.initializeSchema(DatabaseInitializer.kt:148) at io.airbyte.db.init.ConfigsDatabaseInitializer.initializeSchema(ConfigsDatabaseInitializer.kt:20) at io.airbyte.db.init.DatabaseInitializer$DefaultImpls.initialize$lambda$1$lambda$0(DatabaseInitializer.kt:89) at io.airbyte.db.Database.transaction$lambda$0(Database.kt:15) at org.jooq.impl.DefaultDSLContext.lambda$transactionResult0$3(DefaultDSLContext.java:530) at org.jooq.impl.Tools$3$1.block(Tools.java:6358)
k
The error message
ERROR: permission denied for schema public
indicates that the Airbyte user configured for your external database does not have sufficient privileges on the
public
schema. This is a common issue when setting up Airbyte with an external Postgres-compatible database. From the knowledge sources, the required solution is to ensure that the Airbyte user has all necessary privileges on both the database and the
public
schema. Even if you have already granted privileges, sometimes the schema ownership or specific grants may be missing or not applied correctly. Here’s what you should do: 1. Grant All Privileges on the Database and Schema: Make sure the Airbyte user has all privileges on the database and the
public
schema. You can do this by running the following SQL commands as a superuser or a user with sufficient privileges:
Copy code
sql    -- Replace airbyte_user and your_database with your actual user and database names    GRANT ALL PRIVILEGES ON DATABASE your_database TO airbyte_user;    GRANT ALL PRIVILEGES ON SCHEMA public TO airbyte_user;    ALTER SCHEMA public OWNER TO airbyte_user;
2. Check for Ownership: Sometimes, even after granting privileges, the schema owner is not set to the Airbyte user, which can cause permission issues. The
ALTER SCHEMA public OWNER TO airbyte_user;
command above ensures the Airbyte user owns the schema. 3. Apply to All Databases Used by Airbyte: If you are using additional databases for Temporal (such as
temporal
and
temporal_visibility
), repeat the above steps for each database and schema involved in your Airbyte deployment. This approach is confirmed by both user reports and official responses in the knowledge sources, where missing or insufficient privileges on the
public
schema led to similar errors, and the issue was resolved by explicitly granting the necessary permissions and ownership to the Airbyte user [see example](https://github.com/airbytehq/airbyte/issues/60244). If you have already run similar commands, double-check that you are connected to the correct database and that the grants have been applied to the right user and schema. If you are using managed databases (like Azure or AWS RDS), ensure that your user has the ability to modify schema ownership and privileges, as some managed services restrict these operations. If you continue to see the error after applying these changes, please provide the exact SQL commands you used and confirm the user and schema names, so further troubleshooting can be more targeted.
r
@kapa.ai 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"}
k
A message from kapa.ai
The error message:
Copy code
ERROR   Unable to create SQL database.  {"error": "pq: permission denied to create database", ...}
means that the database user configured for Airbyte does not have permission to create new databases in your Postgres instance. This is a common issue when deploying Airbyte with an external Postgres database, especially for the Temporal component, which tries to create the
temporal
and
temporal_visibility
databases if they do not already exist. How to resolve: - Option 1: Grant CREATE DATABASE permission If possible, grant your Airbyte user the
CREATEDB
privilege so it can create the required databases automatically. - Option 2: Manually create the databases If you cannot grant
CREATEDB
(common in production or managed environments), you must manually create the
temporal
and
temporal_visibility
databases, and then grant all privileges on these databases to the Airbyte user. For example:
Copy code
sql   CREATE DATABASE temporal;   GRANT ALL PRIVILEGES ON DATABASE temporal TO airbyte_user;    CREATE DATABASE temporal_visibility;   GRANT ALL PRIVILEGES ON DATABASE temporal_visibility TO airbyte_user;
This approach is confirmed as the solution in multiple user reports and official answers [see here](https://discuss.airbyte.io/t/1544) and [here](https://github.com/airbytehq/airbyte/issues/49304). Summary: You are seeing this error because the Airbyte user does not have permission to create databases. Either grant the necessary permission or manually create the required databases and assign privileges to the Airbyte user.