postgresql 须藤:未知用户:postgres

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/16689934/
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

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-11 00:11:46  来源:igfitidea点击:

sudo: unknown user: postgres

macospostgresql

提问by user1713964

I'm currently trying to run postgresql (9.3) on my iMac but I have some issues with user postgres and psql connection.

我目前正在尝试在我的 iMac 上运行 postgresql (9.3),但是我在用户 postgres 和 psql 连接方面遇到了一些问题。

I bought an iMac old generation (with snow Leopard) that was migrated to Lion. As followed on other StackOverflow topics I added this line on my .bash_profile :

我买了一台迁移到Lion的iMac老一代(有雪豹)。在其他 StackOverflow 主题中,我在 .bash_profile 中添加了这一行:

export PATH=/Library/PostgreSQL/9.3/bin:/usr/bin:$PATH

When launching pg :

启动 pg 时:

sudo su postgres -c '/Library/PostgreSQL/9.3/bin/pg_ctl -D /Library/PostgreSQL/9.3/data/ -m fast start'

it returns :

它返回:

su: unknown login: postgres

What should I do ?

我该怎么办 ?

回答by chancyWu

The default postgres user in OSX 10.8 & 10.9 should be _postgres, you can use sudo -u _postgresto run the command

OSX 10.8 和 10.9 中的默认 postgres 用户应该是_postgres,您可以使用它sudo -u _postgres来运行命令

回答by avjaarsveld

I got this same error (su: unknown login: postgres) when trying sudo su - postgres. I then managed to log in using sudo psql -U my.username postgres.

su: unknown login: postgres在尝试时遇到了同样的错误 ( ) sudo su - postgres。然后我设法使用sudo psql -U my.username postgres.

I could then create the appropriate users, etc.

然后我可以创建适当的用户等。

Hope that helps.

希望有帮助。

回答by Valery Viktorovsky

Try to start from current user:

尝试从当前用户开始:

/Library/PostgreSQL/9.3/bin/pg_ctl -D /Library/PostgreSQL/9.3/data/ -l /usr/local/var/postgres/server.log start

Additional info: How to start PostgreSQL server on Mac OS X?

附加信息:如何在 Mac OS X 上启动 PostgreSQL 服务器?