pg_config-如何更改postgres版本 [英] pg_config - how to change postgres versions
问题描述
默认情况下,我的两台ubuntu 14机器上都有postgres 10版本,但是我在两台机器上都安装了postgres 9.6.
By default I had postgres 10 versions on my two ubuntu 14 machines, but I installed postgres 9.6 on the two of them.
但是其中之一pg_config给我:
But on one of them pg_config give me:
VERSION = PostgreSQL 9.6.6
另一个:
VERSION = PostgreSQL 10.1
它们在以下位置具有相同的libpq-dev软件包:
They have the same libpq-dev packages in:
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文件?
So I was wondering is there a way for me to change the version installed that it gives me postgres 9.6 instead of postgres 10.01? Maybe using the pg_config file?
Tnx,汤姆
更新:在仍然显示postgres 10的实例上,这是结果(表明它尚未安装):
update: on the instance that still shows postgres 10, this is the result(which shows that it is not installed):
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
推荐答案
On: Debian, Ubuntu
bash /usr/bin/pg_config已设置为查找并获取最新的/usr/lib/postgresql/*/pg_config --version
the bash /usr/bin/pg_config is setup to look and get the latest /usr/lib/postgresql/*/pg_config --version available
一种快速的解决方案(不是优雅而脆弱的)可以按照以下方式进行更新.
然后将环境更新为:
A fast solution, NOT elegant and weak, could be to update it as follow.
Then update env as, e.g.:
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
这篇关于pg_config-如何更改postgres版本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!