Postgresql 9.2 pg_dump 版本不匹配
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/12836312/
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
Postgresql 9.2 pg_dump version mismatch
提问by Chris Colla
I am trying to dump a Postgresql database using the pg_dumptool.
我正在尝试使用pg_dump工具转储 Postgresql 数据库。
$ pg_dump books > books.out
How ever i am getting this error.
我怎么会收到这个错误。
pg_dump: server version: 9.2.1; pg_dump version: 9.1.6
pg_dump: aborting because of server version mismatch
The --ignore-version
option is now deprecated and really would not be a a solution to my issue even if it had worked.
该--ignore-version
选项现已弃用,即使它有效,也不会真正解决我的问题。
How can I upgrade pg_dumpto resolve this issue?
如何升级pg_dump以解决此问题?
采纳答案by francs
You can either install PostgreSQL 9.2.1 in the pg_dump
client machine or just copy the $PGHOME
from the PostgreSQL server machine to the client machine. Note that there is no need to initdb
a new cluster in the client machine.
您可以在pg_dump
客户端机器上安装 PostgreSQL 9.2.1,也可以将 PostgreSQL$PGHOME
服务器机器上的 PostgreSQL复制到客户端机器上。请注意,initdb
客户端机器中不需要新集群。
After you have finished installing the 9.2.1 software, remember to edit some environment variables in your .bash_profile
file.
安装完 9.2.1 软件后,记得编辑.bash_profile
文件中的一些环境变量。
回答by Seth
I encountered this while using Heroku on Ubuntu, and here's how I fixed it:
我在 Ubuntu 上使用 Heroku 时遇到了这个问题,这是我修复它的方法:
Add the PostgreSQL apt repository as described at "Linux downloads (Ubuntu) ". (There are similar pages for other operating systems.)
Upgrade to the latest version (9.3 for me) with:
sudo apt-get install postgresql
Recreate the symbolic link in
/usr/bin
with:sudo ln -s /usr/lib/postgresql/9.3/bin/pg_dump /usr/bin/pg_dump --force
The version number in the
/usr/lib/postgresql/...
path above should match theserver version
number in the error you received. So if your error says,pg_dump: server version: 9.9
, then link to/usr/lib/postgresql/9.9/...
.
添加 PostgreSQL apt 存储库,如“ Linux 下载 (Ubuntu) ”中所述。(其他操作系统也有类似的页面。)
升级到最新版本(对我来说是 9.3):
sudo apt-get install postgresql
重新创建符号链接
/usr/bin
:sudo ln -s /usr/lib/postgresql/9.3/bin/pg_dump /usr/bin/pg_dump --force
/usr/lib/postgresql/...
上面路径中的版本号应与server version
您收到的错误中的版本号相匹配。因此,如果您的错误显示为pg_dump: server version: 9.9
,则链接到/usr/lib/postgresql/9.9/...
。
回答by Omer Aslam
Check the installed version(s) of pg_dump:
find / -name pg_dump -type f 2>/dev/null
My output was:
/usr/pgsql-9.3/bin/pg_dump /usr/bin/pg_dump
There are two versions installed. To update pg_dump with the newer version:
sudo ln -s /usr/pgsql-9.3/bin/pg_dump /usr/bin/pg_dump --force
检查 pg_dump 的已安装版本:
find / -name pg_dump -type f 2>/dev/null
我的输出是:
/usr/pgsql-9.3/bin/pg_dump /usr/bin/pg_dump
安装了两个版本。要使用较新的版本更新 pg_dump:
sudo ln -s /usr/pgsql-9.3/bin/pg_dump /usr/bin/pg_dump --force
This will create the symlink to the newer version.
这将创建到较新版本的符号链接。
回答by user2148301
Macs have a builtin /usr/bin/pg_dump
command that is used as default.
Mac 有一个/usr/bin/pg_dump
默认使用的内置命令。
With the postgresql install you get another binary at /Library/PostgreSQL/<version>/bin/pg_dump
安装 postgresql 后,您将获得另一个二进制文件 /Library/PostgreSQL/<version>/bin/pg_dump
回答by Deepak Mahakale
You can just locate pg_dump
and use the full path in command
您可以pg_dump
在命令中找到并使用完整路径
locate pg_dump
/usr/bin/pg_dump
/usr/bin/pg_dumpall
/usr/lib/postgresql/9.3/bin/pg_dump
/usr/lib/postgresql/9.3/bin/pg_dumpall
/usr/lib/postgresql/9.6/bin/pg_dump
/usr/lib/postgresql/9.6/bin/pg_dumpall
Now just use the path of the desired version in the command
现在只需在命令中使用所需版本的路径
/usr/lib/postgresql/9.6/bin/pg_dump books > books.out
回答by Abe Voelker
If you're on Ubuntu, you might have an old version of postgresql-client
installed. Based on the versions in your error message, the solution would be the following:
如果您使用的是 Ubuntu,则可能安装了旧版本postgresql-client
。根据错误消息中的版本,解决方案如下:
sudo apt-get remove postgresql-client-9.1
sudo apt-get install postgresql-client-9.2
回答by solaimuruganv
Every time you upgrade or re install a new version of PostgreSQL, a latest version of pg_dump
is installed.
每次升级或重新安装新版本的 PostgreSQL 时,pg_dump
都会安装最新版本。
There must be a PostgreSQL/bin
directory somewhere on your system, under the latest version of PostgreSQL that you've installed ( 9.2.1 is latest) and try running the
pg_dump
from in there.
PostgreSQL/bin
您的系统上必须有一个目录,在您安装的最新版本的 PostgreSQL 下(9.2.1 是最新版本),然后尝试pg_dump
从那里运行
。
回答by Andreas
For those running Postgres.app:
对于那些运行Postgres.app 的人:
Add the following code to your
.bash_profile
:export PATH=/Applications/Postgres.app/Contents/Versions/latest/bin:$PATH
Restart terminal.
将以下代码添加到您的
.bash_profile
:export PATH=/Applications/Postgres.app/Contents/Versions/latest/bin:$PATH
重启终端。
回答by hcarreras
For Macs with Homebrew. I had this problem when fetching the db from Heroku. I've fixed it just running:
对于带有 Homebrew 的 Mac。从 Heroku 获取数据库时我遇到了这个问题。我已经修复它只是运行:
brew upgrade postgresql
回答by Andrey Yasinishyn
For mac users put to the top of .profile file.
对于 mac 用户,放在 .profile 文件的顶部。
export PATH="/Applications/Postgres.app/Contents/MacOS/bin:$PATH"
then run
然后运行
. ~/.profile