英文:
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;
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论