简体   繁体   English

切换到Mac上的postgres用户

[英]Switch to postgres user on Mac

I would like to su to the postgres user on Mac, so that I can run postgres. 我想su Mac上的postgres用户,这样我可以运行的Postgres。

What am I doing wrong here? 我在这做错了什么?

delirium:~ anna$ sudo su postgres
delirium:~ anna$

Nothing happens. 什么都没发生。 If I try to run postgres, I then get something like this: 如果我尝试运行postgres,那么我得到这样的东西:

delirium:~ anna$ sudo pg_ctl -D /usr/local/var/postgres -l      
/usr/local/var/postgres/server.log startpg_ctl: cannot be run as root
Please log in (using, e.g., "su") as the (unprivileged) user that will
own the server process.

If I try this in order to su , I also get an error: 如果我为了su尝试这个,我也会收到一个错误:

delirium:~ anna$ sudo su - postgres
su: no directory
delirium:~ anna$

What can I do instead? 我该怎么做? I'm fairly sure that the postgres user exists. 我很确定postgres用户存在。

That looks consistent with the postgres user not having a login shell. 这看起来与没有登录shell的postgres用户一致。 Try sudo -u postgres bash 试试sudo -u postgres bash

PostgreSQL is integrated in Server.app available through the App Store in Mountain Lion. PostgreSQL集成在Server.app中,可通过Mountain Lion的App Store获得。

You would have this file: /Library/Server/PostgreSQL/Config/org.postgresql.postgres.plist 你会有这个文件: / Library/Server/PostgreSQL/Config/org.postgresql.postgres.plist

You can sudo: 你可以sudo:

sudo -u _postgres psql template1

Or connect: 或连接:

psql -h localhost -U _postgres postgres

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM