postgresql 架构 public 的所有者会根据我的登录身份发生变化吗?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/20908313/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Owner of schema public changes depending on who I'm logged in as?
提问by Ceili
$ psql postgres
postgres=# \dn
List of schemas
Name | Owner
--------------------+----------
information_schema | postgres
pg_catalog | postgres
pg_toast | postgres
pg_toast_temp_1 | postgres
public | student
(5 rows)
When I log in to psql with user postgres, it shows that schema public is owned by user student. However, when I log in to psql with user student:
当我使用用户 postgres 登录 psql 时,它显示模式 public 归用户 student 所有。但是,当我使用用户 student 登录 psql 时:
$ psql student
student=> \dn
List of schemas
Name | Owner
--------------------+----------
information_schema | postgres
pg_catalog | postgres
pg_toast | postgres
pg_toast_temp_1 | postgres
public | postgres
(5 rows)
It shows that schema public is owned by user postgres.
它表明模式 public 归用户 postgres 所有。
How can I get the ownership of schema public transferred to user student if the user with privileges to do so thinks that it's already done?
如果有权限的用户认为已经完成,如何将模式 public 的所有权转移给用户 student ?
回答by Erwin Brandstetter
This is a misunderstanding. You are logging into two different databases.
这是一种误解。您正在登录两个不同的数据库。
When running
跑步时
$ psql postgres
postgres
is the name of the database. With default configuration the name of the database user is derived from the name of the system user using ident
authenticationautomatically. The only parameter is assumed to be the database name. You do notwant to change anything in the database postgres
, it's a system database for maintenance tasks.
postgres
是数据库的名称。在默认配置下,数据库用户的名称是自动使用ident
身份验证从系统用户的名称派生的。假定唯一的参数是数据库名称。你不希望在数据库中的任何改变postgres
,这对维护任务系统数据库。
The other database is named student
. Each database has a schema public
with its respective owner.
另一个数据库名为student
. 每个数据库都有一个public
带有各自所有者的模式。
Read the manual for psqlor try a lowly man psql
.
To transfer ownership of the schema public
in the database student
, log in as superuser:
要转移public
数据库中架构的所有权,请student
以超级用户身份登录:
psql -U postgres student
Or just (being system user postgres):
或者只是(作为系统用户 postgres):
psql student
And run:
并运行:
ALTER SCHEMA public OWNER TO student;
Details in the manualonce more.
再次在手册中详细说明。