当我执行sudo -u zorgan postgres psql
来启动我的 postgres 会话时,它返回:
postgres: invalid argument: "psql"
如果我删除psql
它会返回:
postgres does not know where to find the server configuration file.
You must specify the --config-file or -D invocation option or set the PGDATA environment variable.
知道问题是什么吗?
https://www.sudo.ws/man/1.8.18/sudo.man.html
[-u 用户] [命令]
所以在您的情况下:
sudo -u zorgan postgres psql
尝试使用参数psql
启动 Postgres 进程,谢天谢地失败了。 如果要使用客户端连接到 Postgres 群集psql
请使用psql
。因此,如果您希望使用 sudo 运行它:
sudo -u zorgan psql postgres
这里Postgres是Psql的参数,它是dbname...
https://www.postgresql.org/docs/current/static/app-psql.html
psql [option...] [dbname [username]]
sudo -u postgres psql
上面的postgres
是用户。