大网数据广告活动
服务器运维问答

My only user is not allowed to login into my postgresql server, what can I do?

· 52CE 我爱测

I think that, accidentally, I changed my user to a role with no log in allowed. Now I can't even log in to give log in privileges to the role. Is there something I can do? I think there was only 1 user and I don't know how to lis…

问题原文

原帖链接 · Lay González · CC BY-SA 3.0

I think that, accidentally, I changed my user to a role with no log in allowed. Now I can't even log in to give log in privileges to the role. Is there something I can do?

I think there was only 1 user and I don't know how to list all my users if I can't log in first.

Thanks

Addendum

I reinstalled postgres and it seems that no postgres user exists. I installed it via brew:

已采纳解答

原帖链接 · Erik Jones · CC BY-SA 3.0

The main superuser account is set up by initdb when run and will default to the current system user name, not postgres, unless an explicit -u/--username argument is given. From your above \du output it's clear that when you set up the server you did it with your laygr system user as that user is the database server's main superuser account.

Should you mess up your login privileges or forget your password you can get back into the server if you have write access to it's data directory in order to be able to edit pg_hba.conf. Just change the auth-method on the relevant line to trust and reload the server's config via pg_ctl reload. You can then log in, fix your user/password, and then revert the changes you made to pg_hba.conf and reload the config again.

摘自公开归档,保留原文语言,版式经整理,外部媒体与邮箱地址已移除。

资料来源与适用范围

资料来源
Server Fault
适用范围
以原帖系统、软件版本与发布日期为准(2017-07-08)
内容语言
中文;命令、路径和错误标识保留技术原文
本地收录日期
2026-11-15
授权说明
CC BY-SA 3.0

正文与所需资源由本站本地存储。查看来源及更新记录 ↗

请按适用版本和实际日志确认原因;本站没有对每一种系统或设备逐项执行文中的操作。