You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

执行GRANT命令后仍无法创建表:Postgres权限不足问题

Postgres权限问题排查
  • 操作流程:

    • 以postgres角色连接Postgres 14实例,创建airflow数据库,同时创建同名用户/角色并设置为该数据库所有者。
    • 初始数据库权限列表:
      List of databases
         Name    |    Owner    | Encoding |   Collate   |    Ctype    |        Access privileges
      -----------+-------------+----------+-------------+-------------+---------------------------------
       airflow   | airflow     | UTF8     | en_HK.UTF-8 | en_HK.UTF-8 |
      
    • 执行授权命令:grant all on database airflow to airflow;,之后数据库权限更新为:
      List of databases
         Name    |    Owner    | Encoding |   Collate   |    Ctype    |        Access privileges
      -----------+-------------+----------+-------------+-------------+---------------------------------
       airflow   | airflow     | UTF8     | en_HK.UTF-8 | en_HK.UTF-8 | =Tc/airflow                    +
                 |             |          |             |             | airflow=CTc/airflow
      
  • 报错信息:
    以airflow用户连接airflow数据库执行建表SQL时,触发权限不足错误:

    sqlalchemy.exc.ProgrammingError: (psycopg2.errors.InsufficientPrivilege) permission denied for schema public
    LINE 2: CREATE TABLE log (
                         ^
    
    [SQL:
    CREATE TABLE log (
            id SERIAL NOT NULL,
            dttm TIMESTAMP WITH TIME ZONE,
            dag_id VARCHAR(250),
            task_id VARCHAR(250),
            map_index INTEGER,
            event VARCHAR(30),
            execution_date TIMESTAMP WITH TIME ZONE,
            owner VARCHAR(500),
            extra TEXT,
            CONSTRAINT log_pkey PRIMARY KEY (id)
    )    
    ]
    
  • 排查发现:
    在pgAdmin中确认,未给airflow用户授予public schema的全部权限:
    pgAdmin中public schema权限截图

内容的提问来源于stack exchange,提问作者moth

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.07.29 14:37:49