首页 > 解决方案 > postgres:无效参数:“psql”

问题描述

当我执行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.

知道问题是什么吗?

标签: linuxpostgresqlsudopsql

解决方案


https://www.sudo.ws/man/1.8.18/sudo.man.html

[-u 用户] [命令]

所以在你的情况下:

sudo -u zorgan postgres psql

尝试使用参数启动 postgres 进程,psql但幸运的是失败了。如果要使用psql客户端连接到 postgres 集群,请使用psql. 所以如果你想用 sudo 运行它:

sudo -u zorgan psql postgres

这里 postgres 是 psql 的参数,它是 dbname...

https://www.postgresql.org/docs/current/static/app-psql.html

psql [选项...] [dbname [用户名]]


推荐阅读