I just installed Postgres 9.6 on CentOS 7. However when I run

[root@server tmp]# /usr/bin/psql --version
psql (PostgreSQL) 9.2.23

It still seems to be pointing to my old version. How do I uninstall the old version (or figure out what its called) without harming the new version?

  • 1
    Besides the version of the software that becomes the default from now on, what do you want to happen to the data (the databases in the old installation)? May 9, 2018 at 8:58

2 Answers 2


The newer version of Postgres will be in /usr/pgsql-9.6 (or a similar location) so you can simply use the alternatives command to make this one the default.

  • Will the "alternatives" command uninstall the old version? One of the objectives is to free up some disk space as well.
    – Dave
    May 8, 2018 at 21:14
  • 3
    Do rpm -qa|grep postgres to find out which package it is then yum remove the packages you don't want. Also yum whatprovides /usr/bin/psql might help find it.
    – Gaius
    May 9, 2018 at 19:24

If you check the running processes ps -ef|grep post you can see which version of postgres is currently running. All you have to do is:

1. Stop the postgres version you want to delete / uninstall.
2. Delete the 'bin' and 'data' directories of the postgres version you just stopped.
3. If you are using tablespaces, delete the contents of your tablespace location as well.
4. Remove entries of the postgres version from file '/etc/postgres-reg.ini' and all the postgres version specific files from '/etc/init.d' location.

BTW, if you have used the one step installer to install the postgres, it creates an uninstall-postgresql file just before the bin directory location. You can use that to uninstall as well, it will automatically perform above steps.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.