本文翻译自:postgres: upgrade a user to be a superuser?
In postgres, how do I change an existing user to be a superuser? 在postgres中,如何将现有用户更改为超级用户? I don’t want to delete the existing user, for various reasons. 出于各种原因,我不想删除现有用户。
# alter user myuser ...?
#1楼
参考:https://stackoom.com/question/j8Ux/postgres-升级用户成为超级用户
#2楼
ALTER USER myuser WITH SUPERUSER;
#3楼
To expand on the above and make a quick reference: 要扩展以上内容并快速参考:
- To make a user a SuperUser:
ALTER USER username WITH SUPERUSER;
为了使用户成为超级用户:ALTER USER username WITH SUPERUSER;
- To make a user no longer a SuperUser:
ALTER USER username WITH NOSUPERUSER;
使用户不再是超级用户:ALTER USER username WITH NOSUPERUSER;
- To just allow the user to create a database:
ALTER USER username CREATEDB;
只是允许用户创建数据库:ALTER USER username CREATEDB;
You can also use CREATEROLE
and CREATEUSER
to allow a user privileges without making them a superuser. 您还可以使用CREATEROLE
和CREATEUSER
来允许用户权限,而不必使其成为超级用户。
#4楼
$ su - postgres
$ su - postgres
$ psql
$ psql
$ \\du;
$ \\du;
for see the user on db 用于在db上查看用户
select the user that do you want be superuser and: 选择您想要成为超级用户的用户:
$ ALTER USER "user" with superuser;
$ ALTER USER "user" with superuser;
#5楼
Run this Command 运行此命令
alter user myuser with superuser;
If you want to see the permission to a user run following command 如果要查看用户的权限,请运行以下命令
\du
#6楼
alter user username superuser;