使用psql命令连接到数据库时出现问题

时间:2014-08-25 07:39:09

标签: postgresql centos psql

我使用CentOS6.3并安装了PostgreSQL9.1服务器。使用psql命令连接到Postgres服务器。

psql -h localhost -U postgres

这是我得到的结果。

postgres=# \c MYDB  
psql (8.4.11, server 9.1.7)  
WARNING: psql version 8.4, server version 9.1.  
         Some psql features might not work.  
You are now connected to database "MYDB".  
MYDB=#

任何人都可以告诉我可能是什么原因。

更新

即使我卸载了PostgreSQL9.1服务器,仍然可以看到以下命令的结果。

`[root@testserver bin]# find / -name 'postgres'
/var/spool/mail/postgres
[root@testserver bin]# find / -name 'psql'
/usr/bin/psql
[root@testserver bin]# which psql
/usr/bin/psql
[root@testserver bin]# which postgres
/usr/bin/which: no postgres in (/usr/lib64/qt-    3.3/bin:/usr/local/bin:/bin:/usr/bin:/usr/local/sbin:/usr/sbin:/sbin:/root/bin)
[root@testserver bin]# psql --version
psql (PostgreSQL) 8.4.11
contains support for command-line editing
[root@testserver bin]#`

这里我的意图是如果你执行哪个psql 命令,如果没有安装服务器,它不应该显示任何输出。但是,我卸载了Postgres服务器并删除了/ opt / PostgreSQL文件夹。

Thabks In Advance。

1 个答案:

答案 0 :(得分:0)

原因是您使用psql版本8.4连接到9.1数据库。

推测psql上的默认PATH是旧版本。

如果使用yum.postgresql.org安装9.1,则应查看输出:

update-alternatives --display pgsql-psql

因为很可能你安装了9.1和8.4,而旧的则设置为默认值。如果是,请运行:

update-alternatives --auto pgsql-psql

自动选择较新版本,或者:

update-alternatives --config pgsql-psql

手动选择要运行的内容。

如果您通过其他方式安装了9.1,则需要使用完整显式/path/to/9.1/bin/psql(当您的9.1安装时),或者将PATH更改为指向bin 1}} dir在系统默认值之前。

相关问题