SQL 找不到本地 psql 命令

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/15576064/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-01 14:25:29  来源:igfitidea点击:

The local psql command could not be located

sqlwindowspostgresqlherokupostgresql-9.2

提问by TheMarron

I'm following the instructions found here.When I try to run $ heroku pg:psqlor $ heroku pg:psql HEROKU POSTGRESQL_BROWNI recieve the following error message:

我正在按照此处找到的说明进行操作当我尝试运行$ heroku pg:psql$ heroku pg:psql HEROKU POSTGRESQL_BROWN收到以下错误消息时:

! The local psql command could not be located ! For help installing psql, see local-postgresql

!找不到本地 psql 命令!有关安装 psql 的帮助,请参阅local-postgresql

I can't find anything useful on the link it gives me (it just links to the instructions I was already using, but further down the page) nor can I find this error anywhere else.

我在它给我的链接上找不到任何有用的东西(它只是链接到我已经在使用的说明,但在页面的更下方),我也无法在其他任何地方找到此错误。

If I've missed anything you need to know to answer this, just let me know. I'm rather new to all this and teaching myself as I go.

如果我错过了您需要知道的任何内容来回答这个问题,请告诉我。我对这一切都很陌生,并在学习过程中自学。

回答by Straff

I had same error even after installing Postgres locally. But after seeing thisI saw that "pqsl" was not in the PATH so I then did

即使在本地安装 Postgres 后,我也遇到了同样的错误。但是在看到这个之后, 我看到“pqsl”不在路径中,所以我做了

PATH=%PATH%;C:\Program Files\PostgreSQL.2\bin

which worked for me

这对我有用

回答by TheMarron

I have since solved this myself. When I ran heroku pg:infoit says the version number is 9.1.8, I was locally running 9.2

从那以后我自己解决了这个问题。当我运行heroku pg:info它说版本号是 9.1.8 时,我在本地运行 9.2

installing 9.1.8 and ensuring Path pointed to the appropriate folder solved the problem.

安装 9.1.8 并确保路径指向适当的文件夹解决了问题。

回答by user1187534

Set the PATH. To find out the PATH of your psql script (on mac) open the sql shell script from your finder in Applications/Postgres installation. This will give you a hint as to where it is installed. That opened a window which told me it is located here: /Library/PostgreSQL/8.4/scripts/runpsql.sh

设置路径。要找出 psql 脚本的 PATH(在 mac 上),请从 Applications/Postgres 安装中的查找器中打开 sql shell 脚本。这将为您提供有关安装位置的提示。这打开了一个窗口,告诉我它位于:/Library/PostgreSQL/8.4/scripts/runpsql.sh

Then, I set the PATH variable from the terminal window by typing:

然后,我通过键入以下内容从终端窗口设置 PATH 变量:

$ PATH="/Library/PostgreSQL/8.4/bin:$PATH"

(depends on the location of your PostgreSQL installation, find your bin path first, another exp: /usr/local/Cellar/[email protected]/9.6.8/bin)

(取决于你的PostgreSQL安装位置,先找到你的bin路径,另一个exp:/usr/local/Cellar/[email protected]/9.6.8/bin)

OR.....

或者.....

You can also connect to the shell by opening the shell directly from your postgres installation folder. Then enter the credentials. If you don't know the credentials, here is how to find them out:

您还可以通过直接从 postgres 安装文件夹打开外壳来连接到外壳。然后输入凭据。如果您不知道凭据,以下是找到它们的方法:

$ heroku pg:info === HEROKU_POSTGRESQL_RED_URL (DATABASE_URL)

$ heroku pg:info === HEROKU_POSTGRESQL_RED_URL (DATABASE_URL)

$ heroku pg:credentials HEROKU_POSTGRESQL_RED_URL

$ heroku pg:credentials HEROKU_POSTGRESQL_RED_URL

回答by drew578

After you change the path, make sure to restart the terminal!

更改路径后,请务必重新启动终端!

回答by Vince Hill

I got rid if this annoying message on Windows by adding a path element without the spaces, i.e.

我通过添加一个没有空格的路径元素来摆脱 Windows 上这条烦人的消息,即

C:\Progra~1\PostgreSQL\9.4\data

C:\Progra~1\PostgreSQL\9.4\data

instead of

代替

“C:\Program Files\PostgreSQL\9.4\data”

“C:\Program Files\PostgreSQL\9.4\data”

回答by friendoflore

I followed the instructions here: http://www.computerhope.com/issues/ch000549.htm, which worked for me if you prefer to go the point-and-click configuration of the PATH variable.

我按照这里的说明进行操作:http: //www.computerhope.com/issues/ch000549.htm,如果您更喜欢点击 PATH 变量的配置,它对我有用。

回答by Michelli Brito

This type of error usually appears in the Windows environment, because if you do not update the PATH after installing Postgresql, heroku pg:psqlcommand does not work.

这类错误通常出现在Windows环境中,因为如果安装Postgresql后不更新PATH,heroku pg:psql命令将不起作用。

So you need to update your PATH environment variable to add the bin directory of your Postgres installation. The directory will look like this: C:\Program Files\PostgreSQL\<VERSION>\bin. For more information, go to the Heroku in Local setup website:

因此,您需要更新 PATH 环境变量以添加 Postgres 安装的 bin 目录。该目录将是这样的: C:\Program Files\PostgreSQL\<VERSION>\bin。有关更多信息,请访问 Heroku in Local 设置网站:

heroku-postgresql: Local setup

heroku-postgresql:本地设置

回答by Paddymac

Just in case anyone is stressing out about why the top answer doesn't work for them.

以防万一有人强调为什么最佳答案对他们不起作用。

My system would not add the Path via cmd with administrator access (Not sure why).

我的系统不会通过具有管理员访问权限的 cmd 添加路径(不知道为什么)。

So check this > Windows key > environment variables > system variables

所以检查这个> Windows键>环境变量>系统变量

And add the last line (your version may differ in the path)

并添加最后一行(您的版本可能在路径上有所不同)

enter image description here

在此处输入图片说明

回答by Robert H

Make sure you've installed the toolbelt as psql is installed by default.

确保您已安装工具带,因为默认情况下已安装 psql。

Howeveryou also need to ensure you've installed a localcopy of PostgreSQL; if you don't the toolbelt will be unable to find the native psql client.

但是,您还需要确保您已经安装了PostgreSQL的本地副本;如果您不这样做,工具带将无法找到本机 psql 客户端。

Assuming you have installed a local copy of PostgreSQL, make sure you can execute psql from the command line directly (i.e make sure you PATH is set correctly ). If the command does not execute, check your PATH, if it does execute see if you can connect via the PSQL connection string provided in the Heroku control panel. If you can connect reinstall the toolbelt, if you are unable to connect provision another dev database and try again.

假设您已经安装了 PostgreSQL 的本地副本,请确保您可以直接从命令行执行 psql(即确保您的 PATH 设置正确)。如果该命令没有执行,请检查您的 PATH,如果它确实执行了,看看您是否可以通过 Heroku 控制面板中提供的 PSQL 连接字符串进行连接。如果您可以连接重新安装工具带,如果您无法连接提供另一个开发数据库并重试。

If there are still issues, I would suggest contacting Heroku support for assistance after verifying no API issues are listed on the status page located here.

如果仍有问题,我建议在确认位于此处的状态页面上未列出 API 问题后,联系 Heroku 支持寻求帮助。

回答by marbiru

I had the same problem and discovered that Heroku doesn't seem to provision the latest version of PostgreSQL by default. Where the Heroku Getting Startedinstructions said

我遇到了同样的问题,发现 Heroku 默认似乎没有提供最新版本的 PostgreSQL。Heroku 入门说明在哪里说

heroku addons:create heroku-postgresql:hobby-dev

heroku 插件:创建 heroku-postgresql:hobby-dev

That provisioned a v10 database for some reason (which you can check by clicking on Heroku Postgres in the Add-ons tab of your dashboard). I deleted that database and provisioned a new database using the --version flag:

由于某种原因,它提供了一个 v10 数据库(您可以通过单击仪表板附加组件选项卡中的 Heroku Postgres 进行检查)。我删除了该数据库并使用 --version 标志配置了一个新数据库:

heroku addons:create heroku-postgresql:hobby-dev --version 11

heroku 插件:创建 heroku-postgresql:hobby-dev --version 11

As of now, at least, you can find the latest version of Postgres supported by Heroku at this link: https://devcenter.heroku.com/articles/heroku-postgresql#version-support-and-legacy-infrastructure

到目前为止,至少,您可以在此链接中找到 Heroku 支持的最新版本的 Postgres:https: //devcenter.heroku.com/articles/heroku-postgresql#version-support-and-legacy-infrastructure

I'm writing this in early 2019, but according to the PostgreSQL websitethe next version (12) is "tentatively scheduled" for third quarter of 2019 so if you're reading this in late 2019 potentially the same problem will come up for v12 instead

我是在 2019 年初写这篇文章的,但根据PostgreSQL 网站的说法,下一版本 (12) 是“暂定”于 2019 年第三季度的,所以如果你在 2019 年末阅读这篇文章,那么 v12 可能会出现同样的问题反而