postgresql psql 和 pg_dump 版本不匹配

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

psql and pg_dump version mismatch

postgresqlpsqlpg-dump

提问by Pablo Fernandez

omnia@ubuntu:~$ psql --version
psql (PostgreSQL) 9.3.4
omnia@ubuntu:~$ pg_dump --version
pg_dump (PostgreSQL) 9.2.8
omnia@ubuntu:~$ dpkg -l | grep pg
ii  gnupg                            1.4.11-3ubuntu2.5                 GNU privacy guard - a free PGP replacement
ii  gpgv                             1.4.11-3ubuntu2.5                 GNU privacy guard - signature verification tool
ii  libgpg-error0                    1.10-2ubuntu1                     library for common error values and messages in GnuPG components
ii  libpq5                           9.3.4-1.pgdg60+1                  PostgreSQL C client library
ii  pgdg-keyring                     2013.2                            keyring for apt.postgresql.org
ii  postgresql-9.2                   9.2.8-1.pgdg60+1                  object-relational SQL database, version 9.2 server
ii  postgresql-9.3                   9.3.4-1.pgdg60+1                  object-relational SQL database, version 9.3 server
ii  postgresql-client-9.2            9.2.8-1.pgdg60+1                  front-end programs for PostgreSQL 9.2
ii  postgresql-client-9.3            9.3.4-1.pgdg60+1                  front-end programs for PostgreSQL 9.3
ii  postgresql-client-common         154.pgdg60+1                      manager for multiple PostgreSQL client versions
ii  postgresql-common                154.pgdg60+1                      PostgreSQL database-cluster manager
ii  python-gnupginterface            0.3.2-9.1ubuntu3                  Python interface to GnuPG (GPG)
ii  unattended-upgrades              0.76ubuntu1                       automatic installation of security upgrades
ii  update-manager-core              1:0.156.14.13                     manage release upgrades
omnia@ubuntu:~$ 

Seems I have both installed but pg_dump is stuck in an older version? Weird since both are linked to the same "wrapper":

似乎我都安装了但 pg_dump 卡在旧版本中?很奇怪,因为两者都链接到同一个“包装器”:

omnia@ubuntu:~$ readlink /usr/bin/psql
../share/postgresql-common/pg_wrapper
omnia@ubuntu:~$ readlink /usr/bin/pg_dump
../share/postgresql-common/pg_wrapper

What am I doing wrong?

我究竟做错了什么?

回答by Henry

sudo rm /usr/bin/pg_dump
sudo ln -s /usr/lib/postgresql/9.3/bin/pg_dump /usr/bin/pg_dump

回答by pinoyyid

If your pg_dumpis sym-linked to pg_wrapper, then the best fix is to tell pg_wrapperwhich version to use.

如果您的pg_dump符号链接到pg_wrapper,那么最好的解决方法是告诉pg_wrapper使用哪个版本。

Append

附加

*   *   9.6     localhost:5432     * 

to /etc/postgresql-common/user_clusters, (assuming your postmaster is listening on localhost:5432 of course).

to /etc/postgresql-common/user_clusters,(当然,假设您的邮政局长正在侦听 localhost:5432)。

This then fixes the problem for all pg_commands, doesn't involve breaking anything, and scales nicely for future versions which you may wish to install.

这然后修复了所有pg_命令的问题,不涉及破坏任何东西,并且可以很好地扩展您可能希望安装的未来版本。

See man pg_wrapperand man postgresqlrcfor details and other options.

有关详细信息和其他选项,请参阅man pg_wrapperman postgresqlrc

NB This answer is specifically for Debian/Ubuntu, and is most likely applicable when there are two version of pg installed, eg. after an upgrade.

注意此答案专门针对 Debian/Ubuntu,并且最有可能适用于安装了两个版本的 pg,例如。升级后。

回答by Martin Konecny

The pgdg60package suffix leads me to believe these packages are not from the official Ubuntu repository. Try looking into /etc/apt/sources.listor /etc/apt/sources.list.dand see if you have any third party PPA's or repositories specified.

pgdg60包后缀使我相信这些软件包不会从Ubuntu官方仓库。尝试查看/etc/apt/sources.list/etc/apt/sources.list.d查看您是否指定了任何第三方 PPA 或存储库。

Try getting the Postgresql packages either from your Ubuntu repo (although these may be a bit out-of-date depending on your Ubuntu version), or from the official postgres repo (they provide an apt server for Ubuntu/Debian): https://wiki.postgresql.org/wiki/Apt

尝试从您的 Ubuntu 存储库(尽管根据您的 Ubuntu 版本这些可能有点过时)或从官方 postgres 存储库(它们为 Ubuntu/Debian 提供 apt 服务器)获取 Postgresql 软件包:https:/ /wiki.postgresql.org/wiki/Apt