[How To] Fix psql version 8.4, server version 9.2 warning

If you have more than one version of PostgreSQL installed in your Linux server, which is very common given the older version of the database shipped with most stable server distros, you may end up with the following warning when trying to login to the database console

bash-4.1$ psql
psql (8.4.20, server 9.2.9)
WARNING: psql version 8.4, server version 9.2.
         Some psql features might not work.
Type “help” for help.

postgres=# q

So basically, you will see that you have the 9.2 version installed but psql script is from the older version. In my case its the oldest version (8.4).  Tying to find the path leads you to /usr/bin

bash-4.1$ which -a psql

In RHEL, if you have not manually installed Postgres, the yum installed version will install the newer version in /usr/pgsql-9.x . Following that logic, the psql version for 9.x will also be in the same folder path i.e /usr/pgsql-9.x/bin/. In my case its version 9.2.
# ls -lrt /usr/bin/psql
-rwxr-xr-x. 1 root root 342984 Feb 18  2014 /usr/bin/psql
Now, lets make sure, the newer version links to the default path set. 
# mv /usr/bin/psql /usr/bin/psql-bk
# ln -s  /usr/pgsql-9.2/bin/psql /usr/bin/psql
That’s it! Now you  should be able to use the psql version of the latest  version of the database
# su – postgres
-bash-4.1$ psql
psql (9.2.9)
Type “help” for help.

Leave a Reply

Scroll to Top
%d bloggers like this: