postgresql 如何修复 pg_dump 版本不匹配错误?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/14168920/
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-10 23:57:05  来源:igfitidea点击:

How to fix pg_dump version mismatch errors?

postgresqlosx-mountain-lionuninstallpg-dump

提问by user1147171

When trying to get local data to Heroku, I am encountering a version mismatch between two different versions of pg_dump.

在尝试将本地数据发送到 Heroku 时,我遇到了两个不同版本的 pg_dump 之间的版本不匹配。

Specifically, I am getting this message:

具体来说,我收到这条消息:

pg_dump: server version: 9.2.2; pg_dump version: 9.1.4
pg_dump: aborting because of server version mismatch

I have found others with this problem, but do not know enough to implement the proposed solutions. (I am new to Ruby on Rails, PostgreSQL, Heroku, and the Mac! Very much at the stage of playing around the picking things up as I go.)

我发现其他人也有这个问题,但对实施建议的解决方案还不够了解。(我是 Ruby on Rails、PostgreSQL、Heroku 和 Mac 的新手!非常处于我边走边捡东西的阶段。)

I was thinking I might simplify my life if I uninstalled all PostgreSQL on my local machine and started again with a clean install of PostgreSQL 9.2.2 from http://postgresapp.com/, but I don't know how to go about doing the uninstall.

我想如果我在本地机器上卸载所有 PostgreSQL 并重新开始从http://postgresapp.com/干净安装 PostgreSQL 9.2.2,我可能会简化我的生活,但我不知道该怎么做卸载。

I'm running Mac OS X Mountain Lion 10.8.2.

我正在运行 Mac OS X Mountain Lion 10.8.2。

回答by Daniel Vérité

OS X 10.8 comes with pg_dumpversion 9.1.4 in the /usr/bindirectory, along with psqland other programs that are client-sidePostgreSQL tools. It does not mean that PostgreSQL as a server is installed (unless you have OS X Server Edition). So you don't have to uninstall PostgreSQL because it's not installed and it's better not to remove these postgres client tools in /usr/binbecause they belong to the system as shipped by Apple. They just need to be side-stepped.

OS X 10.8pg_dump/usr/bin目录中包含9.1.4 版,以及psql其他客户端PostgreSQL 工具程序。这并不意味着安装了 PostgreSQL 作为服务器(除非您有 OS X Server Edition)。所以你不必卸载 PostgreSQL,因为它没有安装,最好不要删除这些 postgres 客户端工具,/usr/bin因为它们属于 Apple 提供的系统。他们只需要回避。

The package provided by postgres.app comprises both the PostgreSQL server and the client-side tools of the same version as this server. These tools get installed in /Applications/Postgres.app/Contents/MacOS/bin

postgres.app 提供的包包括 PostgreSQL 服务器和与该服务器版本相同的客户端工具。这些工具安装在/Applications/Postgres.app/Contents/MacOS/bin

To use these instead of the 9.1 ones from Apple when you work in a Terminal, postgres.app documentationsays to do:

要在终端中工作时使用这些而不是 Apple 的 9.1 版本,postgres.app文档说要这样做:

PATH="/Applications/Postgres.app/Contents/MacOS/bin:$PATH"

and put it in your .profilefile.

并将其放入您的.profile文件中。

Once you have done that and you run pg_dump, you should no longer get the error that's it's the wrong version, because it would be the one that ships with postgres.app (currently 9.2.2).

一旦完成并运行pg_dump,您就不会再收到错误版本的错误消息,因为它将是 postgres.app(当前为 9.2.2)附带的版本。

I have this setup and it works OK for me.

我有这个设置,它对我来说工作正常。

回答by drjorgepolanco

If you only need to upgrade your pg_dump to the latest version and you have homebrew and mac, if the app has the latest version and your local pg doesn't:

如果您只需要将 pg_dump 升级到最新版本并且您有自制软件和 mac,如果应用程序有最新版本而您的本地 pg 没有:

brew upgrade postgresql

brew upgrade postgresql

回答by user1322092

If you're using postgresapp 9.3.x, the path is different. The following worked for me (courtesy of http://sigmyers.com/blog/2013/3/12/postgres-pgdump-version-mismatch-error-postgresapp-postgresappcom)

如果您使用的是 postgresapp 9.3.x,则路径不同。以下对我有用(由http://sigmyers.com/blog/2013/3/12/postgres-pgdump-version-mismatch-error-postgresapp-postgresappcom 提供

export PG_BIN_PATH="/Applications/Postgres.app/Contents/Versions/9.3/bin/"
PATH=$PG_BIN_PATH:$PATH

Check here for the latest path: http://postgresapp.com/documentation/cli-tools.html

在此处查看最新路径:http: //postgresapp.com/documentation/cli-tools.html

回答by samvax

I'm running Mountain Lion Server. My PostgeSQL server is at version 9.2.1 and the default tools are at 9.1.5.

我正在运行 Mountain Lion Server。我的 PostgeSQL 服务器版本为 9.2.1,默认工具版本为 9.1.5。

I had to use:

我不得不使用:

PATH="/Applications/Server.app/Contents/ServerRoot/usr/bin:$PATH"

to make it work.

使其工作。

回答by Lukasz Muzyka

Yep, sometimes if you run Postgres.app this may happen after upgrade. Make sure you restart your Postgres.app - it will update your PATH.

是的,有时如果您运行 Postgres.app,这可能会在升级后发生。确保您重新启动 Postgres.app - 它会更新您的 PATH。

回答by Michel Anderson Lütz Teixeira

In my case I have postgresql installed via homebrew and the executables are here: /usr/local/opt/[email protected]/bin

就我而言,我通过自制软件安装了 postgresql,可执行文件在这里:/usr/local/opt/[email protected]/bin

Or you copy the dump and restore executions to the /Applications/Postgres.app/Contents/SharedSupport folder

或者您将转储和恢复执行复制到 /Applications/Postgres.app/Contents/SharedSupport 文件夹

or in PdAgmin you point the PG bin Path (in properties -> binary Path) to the path of the executables of your postgre

或在 PdAgmin 中,您将 PG bin 路径(在属性 -> 二进制路径中)指向 postgre 可执行文件的路径