【问题标题】:postgres: invalid argument: "psql"postgres:无效参数:“psql”
【发布时间】:2018-10-24 03:09:35
【问题描述】:

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

知道问题出在哪里吗?

【问题讨论】:

  • 取决于您尝试做什么...您对 sudo -u zorgan postgres psql 的期望是什么?...
  • 我只是想启动一个 postgres 会话,这样我就可以创建我的数据库,类似于这里:digitalocean.com/community/tutorials/…(但是我在我的本地服务器而不是远程服务器上执行此操作)跨度>
  • sudo -u zorgan postgres 将以 Linux 用户 zorgan 的身份运行一个名为 postgres 的程序 - 我怀疑这就是你想要的。如果您已经有一个用户zorgan,那么为什么不直接使用以下方式提供用户名:psql -U zorgan
  • 您可能不应该以psql 作为参数运行postgres 二进制文件,而应该运行psql 二进制文件。将postgres 从该命令行中删除。
  • sudo -u zorgan psql postgres?..

标签: linux postgresql sudo psql


【解决方案1】:

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

[-u 用户] [命令]

所以在你的情况下:

sudo -u zorgan postgres psql

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

sudo -u zorgan psql postgres

这里 postgres 是 psql 的参数,也就是 dbname...

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

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

【讨论】:

    【解决方案2】:

    sudo -u postgres psql

    上面的postgres是用户。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2019-02-21
      • 2016-07-31
      • 1970-01-01
      • 2020-10-13
      • 2021-05-26
      • 2016-07-07
      • 2014-10-04
      • 2013-03-29
      相关资源
      最近更新 更多