【问题标题】:Cannot Run Postgres (psql) locally无法在本地运行 Postgres (psql)
【发布时间】:2015-01-06 21:39:03
【问题描述】:

每当我尝试在本地运行psql$ psql -d template1 -U postgres 时,我都会收到-bash: psql: command not found

我已经安装了 Postgres Mac 应用程序,但是当我点击打开 psql 时,我得到...

Last login: Tue Jan  6 16:30:17 on ttys001
admins-MacBook-Air:~ surajkapoor$ /Applications/Postgres.app/Contents/MacOS/bin/psql ; exit;
psql: FATAL:  database "surajkapoor" does not exist
logout

[Process completed]

这对我来说没有意义。我假设在本地安装 mac app install postgres。

【问题讨论】:

  • 为什么在使用psql时指定需要的参数,而在使用工具的完整路径时却没有?

标签: macos postgresql psql


【解决方案1】:

您需要将 psql 文件所在的目录添加到 mac 的 PATH 变量中

/Applications/Postgres.app/Contents/MacOS/bin/

不带参数打开 psql 将尝试使用当前用户的名称连接到数据库,如果您不想将目录添加到 PATH 变量中,您可以将整个地址放在控制台上,它应该可以工作

/Applications/Postgres.app/Contents/MacOS/bin/psql -d template1 -U postgres

【讨论】:

    猜你喜欢
    • 2020-06-26
    • 2020-06-06
    • 2022-11-10
    • 2019-02-21
    • 2017-01-21
    • 2022-11-02
    • 2021-09-25
    • 2012-11-26
    • 2017-11-23
    相关资源
    最近更新 更多