Postgresql

如何在 CentOS 7 上解除安裝舊版本的 Postgres?

  • May 9, 2018

我剛剛在 CentOS 7 上安裝了 Postgres 9.6。但是當我執行

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

它似乎仍然指向我的舊版本。如何在不損害新版本的情況下解除安裝舊版本(或找出它的名稱)?

較新版本的 Postgres 將位於/usr/pgsql-9.6(或類似位置),因此您可以簡單地使用替代命令將其設為預設值。

如果您檢查正在執行的程序ps -ef|grep post,您可以看到目前正在執行的 postgres 版本。你所要做的就是:

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.

順便說一句,如果您使用一步安裝程序來安裝 postgres,它會在目錄位置uninstall-postgresql之前創建一個文件。bin您也可以使用它來解除安裝,它會自動執行上述步驟。

引用自:https://dba.stackexchange.com/questions/206189