pg_config - 如何更改postgres版本

时间:2018-02-01 12:17:53

标签: postgresql ubuntu config

默认情况下,我的两台ubuntu 14机器上有10个版本的postgres,但我在其中两台机器上安装了postgres 9.6。

但是其中一个pg_config给我:

VERSION = PostgreSQL 9.6.6

另一个:

VERSION = PostgreSQL 10.1

它们具有相同的libpq-dev软件包:

dpkg -l | grep libpq-dev

libpq-dev  10.1-1.pgdg14.04+1  amd64 header files for libpq5 (PostgreSQL library)

所以我想知道有没有办法让我更改安装的版本,它给了我postgres 9.6而不是postgres 10.01?也许使用pg_config文件?

TNX, 汤姆

更新: 在仍然显示postgres 10的实例上,这是结果(显示它未安装):

ii  pgdg-keyring                         2017.3                                     all          keyring for apt.postgresql.org
ii  postgresql-9.6                       9.6.6-1.pgdg14.04+1                        amd64        object-relational SQL database, version 9.6 server
ii  postgresql-client-9.6                9.6.6-1.pgdg14.04+1                        amd64        front-end programs for PostgreSQL 9.6
ii  postgresql-client-common             189.pgdg14.04+1                            all          manager for multiple PostgreSQL client versions
ii  postgresql-common                    189.pgdg14.04+1                            all          PostgreSQL database-cluster manager
ii  postgresql-contrib-9.6               9.6.6-1.pgdg14.04+1                        amd64        additional facilities for PostgreSQL

1 个答案:

答案 0 :(得分:0)

重复:pg_config shows 9.4 instead of 9.3

在:Debian、Ubuntu

bash /usr/bin/pg_config 设置为查看并获取最新的 /usr/lib/postgresql/*/pg_config --version 可用

一个快速的解决方案,不优雅和弱,可能是更新如下。
然后将 env 更新为,例如:

export FORCE_PGCONFIG=/usr/lib/postgresql/12/pg_config

/usr/bin/pg_config(更新):

PGBINROOT="/usr/lib/postgresql/"
#redhat# PGBINROOT="/usr/pgsql-"
# user edit :
if [ -n "$FORCE_PGCONFIG" ]; then
    # up to you to set it properly...
    LATEST_SERVER_DEV="$FORCE_PGCONFIG";
else
    LATEST_SERVER_DEV=`ls -v $PGBINROOT*/bin/pg_config 2>/dev/null|tail -n1`;
fi
# end user edit ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

if [ -n "$LATEST_SERVER_DEV" ]; then
    exec "$LATEST_SERVER_DEV" "$@"
else
    if [ -x /usr/bin/pg_config.libpq-dev ]; then
    exec /usr/bin/pg_config.libpq-dev "$@"
    else
    echo "You need to install postgresql-server-dev-NN for building a server-side extension or libpq-dev for building a client-side application." >&2
    exit 1
    fi
fi