Accidently removed postgres default superuser privileges - can I get it back?

℡╲_俬逩灬. 提交于 2019-11-30 20:47:38

问题


From inside Webmin I accidently unmarked the checkbox "Can create databases?" and "Can create users?"

Stupid, I know.

But since it takes a user with superuser privileges to edit/create a user, is there a way to fix this from the linux terminal?

I know it's possible to reset a password, but I haven't been able to find out how to reset the default superuser postgres' roles/privileges. Is this even possible or do I have to do a reinstall?


回答1:


there's a single-user mode where you always have superuser capabilities:

as root

service postgresql stop

as user postgres: (you may need to change the version number (here 9.1) Non .deb distros will probably have a different path here too. the first path is the postgres binary, the second one is the directory that contains postgresql.conf.

/usr/lib/postgresql/9.1/bin/postgres --single -D /etc/postgresql/9.1/main/

on the new command line

alter user postgres with superuser;

ctrl-d to exit.

as root:

service postgresql start

A similar strategy can use used to set or reset passwords etc.



来源:https://stackoverflow.com/questions/27777076/accidently-removed-postgres-default-superuser-privileges-can-i-get-it-back

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!