【发布时间】:2018-08-22 19:18:36
【问题描述】:
我需要恢复postgres用户的超级用户权限,因为它失去了超级用户资格。
我不能在psql shell 中做任何事情,它会给出消息
must be superuser to create superusers
系统是 Ubuntu 16.04 和 PostgreSQL 9.5。
我可以恢复这个postgres 用户吗?
【问题讨论】:
标签: postgresql superuser
我需要恢复postgres用户的超级用户权限,因为它失去了超级用户资格。
我不能在psql shell 中做任何事情,它会给出消息
must be superuser to create superusers
系统是 Ubuntu 16.04 和 PostgreSQL 9.5。
我可以恢复这个postgres 用户吗?
【问题讨论】:
标签: postgresql superuser
如果您设法删除所有用户的超级用户权限,则必须以单用户模式启动数据库:
作为操作系统用户postgres停止数据库服务器:
/path/to/postgresql/bin/pg_ctl stop -D /path/to/data/directory
以单用户模式启动服务器:
/path/to/postgresql/bin/postgres --single -D /path/to/data/directory postgres
现在你是超级用户了。
恢复超级用户权限:
ALTER ROLE postgres SUPERUSER
使用 CTRL+D(或 CTRL+Z 退出会话在 Windows 上)。
以通常的方式重新启动 PostgreSQL。
【讨论】: