PostgreSQL ERROR: 必须是 public 模式的所有者

huangapple go评论86阅读模式
英文:

PostgreSQL ERROR: must be owner of schema public

问题

显示我以用户名“postgres”登录,这恰好是“mvp”数据库的所有者。然而,我收到一个错误消息,指出我不是所有者。

英文:

I am new to Postgres and am having an issue dropping all tables in a database. I have a database named "mvp" and the owner is set as "postgres." I did the following in my terminal:

psql -d mvp postgres -W
postgres=> \l
                            List of databases
   Name    |  Owner   | Encoding | Collate | Ctype |  Access privileges  
-----------+----------+----------+---------+-------+---------------------
 mvp       | postgres | UTF8     | C       | C     | 
postgres=> \c mvp
You are now connected to database "mvp" as user "postgres".
mvp=> DROP SCHEMA public CASCADE;
ERROR:  must be owner of schema public

It is showing that I am logged in as the user "postgres" which happens to be the owner of the "mvp" database. However, I am receiving an error message saying I am not the owner.

答案1

得分: 1

\n除非您在此之前已更改了模式 public 的所有权,否则数据库所有者 postgres 将是该模式的所有者。因此,您需要连接作为用户 postgres 或超级用户来删除该模式。

逐步执行以下方法:

  • 查找谁拥有模式 public

    \dn public
    
  • 成为该用户

    \c - username
    
  • 删除模式

    DROP SCHEMA public CASCADE;
    
英文:

Unless you have changed the ownership of schema public before, postgres (the owner of the database) would be the owner of that schema. So you'd have to connect as user postgres or a superuser to drop the schema.

To approach that methodically:

  • find out who owns schema public

    \dn public
    
  • become that user

    \c - username
    
  • drop the schema

    DROP SCHEMA public CASCADE;
    

huangapple
  • 本文由 发表于 2023年2月19日 03:20:36
  • 转载请务必保留本文链接:https://go.coder-hub.com/75495806.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定