问题:Mac上切换到postgres用户

我想把su给 Mac 上的 postgres 用户,这样我就可以运行 postgres。

我在这里做错了什么?

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

什么都没发生。如果我尝试运行 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.

如果我为了su尝试这个,我也会得到一个错误:

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

我能做些什么呢?我相当确定 postgres 用户存在。

解答

这看起来与没有登录 shell 的 postgres 用户一致。试试sudo -u postgres bash

Logo

PostgreSQL社区为您提供最前沿的新闻资讯和知识内容

更多推荐