How do I correct the mismatch of psql version and

2020-04-06 00:52发布

Somewhere along the line I have ended up with a version mismatch between postgresql-9.4 and psql which is version 9.3 despite the fact that version 9.4 is installed. I think I need to correct the $PATH variable but I don't know where to find this. I've looked in my /etc/.bashrc file and can't see anything that points me in the right direction.

When I do sudo find / -name psql the result is:

/usr/bin/psql
/usr/share/bash-completion/completions/psql
/usr/pgsql-9.4/bin/psql

yum list installed | grep postgres yields the following:

postgresql.x86_64                9.3.9-1.fc21                          @updates 
postgresql-contrib.x86_64        9.3.9-1.fc21                          @updates 
postgresql-devel.x86_64          9.3.9-1.fc21                          @updates 
postgresql-libs.x86_64           9.3.9-1.fc21                          @updates 
postgresql-server.x86_64         9.3.9-1.fc21                          @updates 
postgresql94.x86_64              9.4.5-1PGDG.f21                       @pgdg94  
postgresql94-libs.x86_64         9.4.5-1PGDG.f21                       @pgdg94  
postgresql94-server.x86_64       9.4.5-1PGDG.f21                       @pgdg94 

标签: postgresql
3条回答
倾城 Initia
2楼-- · 2020-04-06 01:29

Use the alternatives mechanism. On Fedora:

sudo update-alternatives --config pgsql-psql
查看更多
够拽才男人
3楼-- · 2020-04-06 01:40

As Craig Ringer answered - generally you should use:

sudo update-alternatives --config pgsql-psql

Nevertheless, sometimes you can get such message back:

failed to link /usr/bin/psql -> /etc/alternatives/pgsql-psql: /usr/bin/psql exists and it is not a symlink

If so - try:

ln -s /usr/pgsql-[PUT YOUR VERSION HERE(ex. 9.6)]/bin/psql /usr/local/bin/psql
查看更多
聊天终结者
4楼-- · 2020-04-06 01:42

You're apparently using CentOS or RHEL.

In this case, you might: 1) invoke psql with the full path or 2) replace the current psql in the alternatives by executing the following command as root:

update-alternatives --install /usr/bin/psql pgsql-psql /usr/pgsql-9.4/bin/psql 1

A tip: use updatedb and locate instead of find whenever looking for a file or directory. :D

查看更多
登录 后发表回答