CentOS 5:我的 Postgresql 服务器版本与我的 psql 客户端不同。我该怎么办?

Abe*_*ego 3 centos postgresql

我在 CentOS 5 x86_64 VPS 中安装了 PostgreSQL 9.1,使用以下命令:

我指定了要安装哪个 Postgresql 版本,所以我选择 9.1,因为我想将开发环境和生产环境等同起来:

wget http://yum.pgrpms.org/9.1/redhat/rhel-5-x86_64/pgdg-centos91-9.1-4.noarch.rpm
Run Code Online (Sandbox Code Playgroud)

进而

yum install postgresql91-server
Run Code Online (Sandbox Code Playgroud)

最后

service postgresql-9.1 initdb
chkconfig postgresql-9.1 on
service postgresql-9.1 start
Run Code Online (Sandbox Code Playgroud)

完成所有这些并创建我的数据库后,我运行psql myfirstdb并收到此警告:

Welcome to psql 8.1.23 (server 9.1.11), the PostgreSQL interactive terminal.

Type:  \copyright for distribution terms
       \h for help with SQL commands
       \? for help with psql commands
       \g or terminate with semicolon to execute query
       \q to quit

WARNING:  You are connected to a server with major version 9.1,
but your psql client is major version 8.1.  Some backslash commands,
such as \d, might not work properly.
Run Code Online (Sandbox Code Playgroud)

所以,也就是说我有 9.1 服务器并使用 psql 客户端 8.1,并且一些命令\d不起作用。

我该如何修复它们?

小智 5

很可能您有多个版本的 PostgreSQL 并且使用了错误版本的 psql。尝试

sudo find / -name psql
Run Code Online (Sandbox Code Playgroud)

然后检查文件的版本并通过设置 PATH 使用正确的版本。

 /usr/pgsql-9.3/bin/psql -V
psql (PostgreSQL) 9.3.2
Run Code Online (Sandbox Code Playgroud)

你也可以试试

yum list installed | grep postgres
Run Code Online (Sandbox Code Playgroud)

查看您的系统中有哪些版本的 PostgreSQL。


Jen*_*y D 1

psql 客户端位于与 psql 服务器不同的包中。它通常称为 postgresql-client。