卸載apt-get安裝的PostgreSQL版本實現(xiàn)
卸載通過apt-get安裝的PostgreSQL 就版本,可以按照以下步驟進行。
查找已安裝的PostgreSQL包
在卸載之前,建議先查找并確認(rèn)已安裝的PostgreSQL包及其版本。
可以使用以下命令來查找與PostgreSQL相關(guān)的所有已安裝包:
dpkg -l | grep postgresql
例:
root@autodl-container-616f40a3b3-41cb82d9:~# dpkg -l | grep postgresql ii postgresql 10+190ubuntu0.1 all object-relational SQL database (supported version) ii postgresql-10 10.23-0ubuntu0.18.0 amd64 object-relational SQL database, version 10 server ii postgresql-client 10+190ubuntu0.1 all front-end programs for PostgreSQL (supported version) ii postgresql-client-10 10.23-0ubuntu0.18.0 amd64 front-end programs for PostgreSQL 10 ii postgresql-client-common 190ubuntu0.1 all manager for multiple PostgreSQL client versions ii postgresql-common 190ubuntu0.1 all PostgreSQL database-cluster manager ii postgresql-server-dev-10 10.23-0ubuntu0.18.0 amd64 development files for PostgreSQL 10 server-side programming ii postgresql-server-dev-all 190ubuntu0.1 all extension build tool for multiple PostgreSQL versions
卸載PostgreSQL:
使用apt-get的–purge remove選項來卸載PostgreSQL及其配置文件。
通常apt-get卸載時不需要指定小版本號,因為它會卸載所有相關(guān)的PostgreSQL包。
不過,如果出于某種原因你需要更精確地指定版本,可能需要查找確切的包名(這通常包括版本號)。但大多數(shù)情況下,以下命令就足夠了:
sudo apt-get --purge remove postgresql*
這個命令會卸載所有以“postgresql”開頭的包,包括PostgreSQL服務(wù)器、客戶端庫、文檔等。–purge選項會同時刪除配置文件。
例:
root@autodl-container-616f40a3b3-41cb82d9:/usr/lib/postgresql# cd ~ root@autodl-container-616f40a3b3-41cb82d9:~# apt-get --purge remove postgresql* Reading package lists... Done Building dependency tree Reading state information... Done Note, selecting 'postgresql-10-pgrouting' for glob 'postgresql*' Note, selecting 'postgresql-common' for glob 'postgresql*' Note, selecting 'postgresql-10-pgrouting-doc' for glob 'postgresql*' Note, selecting 'postgresql-10-repmgr' for glob 'postgresql*' Note, selecting 'postgresql-9.2-repmgr' for glob 'postgresql*' Note, selecting 'postgresql-10-dirtyread' for glob 'postgresql*' Note, selecting 'postgresql-pltcl' for glob 'postgresql*' Note, selecting 'postgresql-10-asn1oid' for glob 'postgresql*' Note, selecting 'postgresql-contrib-10' for glob 'postgresql*' Note, selecting 'postgresql-server-dev-all' for glob 'postgresql*' Note, selecting 'postgresql-plv8' for glob 'postgresql*' Note, selecting 'postgresql-10-postgis-2.2-scripts' for glob 'postgresql*' Note, selecting 'postgresql-10-unit' for glob 'postgresql*' Note, selecting 'postgresql-10-pgfincore' for glob 'postgresql*' Note, selecting 'postgresql-10-prioritize' for glob 'postgresql*' Note, selecting 'postgresql-10-postgis-scripts' for glob 'postgresql*' Note, selecting 'postgresql-10-pldebugger' for glob 'postgresql*' Note, selecting 'postgresql-10-mimeo' for glob 'postgresql*' Note, selecting 'postgresql-9.5-repmgr' for glob 'postgresql*' Note, selecting 'postgresql-10-python3-multicorn' for glob 'postgresql*' Note, selecting 'postgresql-10-bgw-replstatus' for glob 'postgresql*' Note, selecting 'postgresql-10-postgis-2.4' for glob 'postgresql*' Note, selecting 'postgresql-10-amcheck' for glob 'postgresql*' Note, selecting 'postgresql-10-jsquery' for glob 'postgresql*' Note, selecting 'postgresql-filedump' for glob 'postgresql*' Note, selecting 'postgresql-10-pgmemcache' for glob 'postgresql*' Note, selecting 'postgresql-10-postgis-2.4-scripts' for glob 'postgresql*' Note, selecting 'postgresql-10-ogr-fdw' for glob 'postgresql*' Note, selecting 'postgresql-10-pglogical' for glob 'postgresql*' Note, selecting 'postgresql-10-postgis-2.3-scripts' for glob 'postgresql*' Note, selecting 'postgresql-python3-multicorn' for glob 'postgresql*' Note, selecting 'postgresql-postgis-java' for glob 'postgresql*' Note, selecting 'postgresql-10-pgrouting-scripts' for glob 'postgresql*' Note, selecting 'postgresql-10-pgsphere' for glob 'postgresql*' Note, selecting 'postgresql-10-pgtap' for glob 'postgresql*' Note, selecting 'postgresql-doc-10' for glob 'postgresql*' Note, selecting 'postgresql-python-multicorn' for glob 'postgresql*' Note, selecting 'postgresql-10-cron' for glob 'postgresql*' Note, selecting 'postgresql-all' for glob 'postgresql*' Note, selecting 'postgresql-10-pgmp' for glob 'postgresql*' Note, selecting 'postgresql-9.3-repmgr' for glob 'postgresql*' Note, selecting 'postgresql-10-pgq3' for glob 'postgresql*' Note, selecting 'postgresql-10-plproxy' for glob 'postgresql*' Note, selecting 'postgresql-7.4' for glob 'postgresql*' Note, selecting 'postgresql-9.0-repmgr' for glob 'postgresql*' Note, selecting 'postgresql-doc' for glob 'postgresql*' Note, selecting 'postgresql-8.0' for glob 'postgresql*' Note, selecting 'postgresql-10-debversion' for glob 'postgresql*' Note, selecting 'postgresql-10' for glob 'postgresql*' Note, selecting 'postgresql-10-q3c' for glob 'postgresql*' Note, selecting 'postgresql-10-prefix' for glob 'postgresql*' Note, selecting 'postgresql-10-slony1-2' for glob 'postgresql*' Note, selecting 'postgresql-pgtap' for glob 'postgresql*' Note, selecting 'postgresql-9.1' for glob 'postgresql*' Note, selecting 'postgresql-9.3' for glob 'postgresql*' Note, selecting 'postgresql-9.4' for glob 'postgresql*' Note, selecting 'postgresql-9.5' for glob 'postgresql*' Note, selecting 'postgresql-9.6' for glob 'postgresql*' Note, selecting 'postgresql-10-plr' for glob 'postgresql*' Note, selecting 'postgresql-client' for glob 'postgresql*' Note, selecting 'postgresql-10-citus' for glob 'postgresql*' Note, selecting 'postgresql-10-pgextwlist' for glob 'postgresql*' Note, selecting 'postgresql-10-plsh' for glob 'postgresql*' Note, selecting 'postgresql-10-plv8' for glob 'postgresql*' Note, selecting 'postgresql-10-pgaudit' for glob 'postgresql*' Note, selecting 'postgresql-plperl' for glob 'postgresql*' Note, selecting 'postgresql-10-mysql-fdw' for glob 'postgresql*' Note, selecting 'postgresql-9.6-repmgr' for glob 'postgresql*' Note, selecting 'postgresql-10-rum' for glob 'postgresql*' Note, selecting 'postgresql-hll' for glob 'postgresql*' Note, selecting 'postgresql' for glob 'postgresql*' Note, selecting 'postgresql-10-ip4r' for glob 'postgresql*' Note, selecting 'postgresql-10-powa' for glob 'postgresql*' Note, selecting 'postgresql-contrib' for glob 'postgresql*' Note, selecting 'postgresql-10-slony1' for glob 'postgresql*' Note, selecting 'postgresql-plpython3' for glob 'postgresql*' Note, selecting 'postgresql-10-pgq-node' for glob 'postgresql*' Note, selecting 'postgresql-server' for glob 'postgresql*' Note, selecting 'postgresql-q3c' for glob 'postgresql*' Note, selecting 'postgresql-plpython' for glob 'postgresql*' Note, selecting 'postgresql-plr' for glob 'postgresql*' Note, selecting 'postgresql-10-partman' for glob 'postgresql*' Note, selecting 'postgresql-autodoc' for glob 'postgresql*' Note, selecting 'postgresql-10-orafce' for glob 'postgresql*' Note, selecting 'postgresql-10-pllua' for glob 'postgresql*' Note, selecting 'postgresql-pltcl-10' for glob 'postgresql*' Note, selecting 'postgresql-10-repack' for glob 'postgresql*' Note, selecting 'postgresql-10-preprepare' for glob 'postgresql*' Note, selecting 'postgresql-comparator' for glob 'postgresql*' Note, selecting 'postgresql-9.4-repmgr' for glob 'postgresql*' Note, selecting 'postgresql-pgsphere' for glob 'postgresql*' Note, selecting 'postgresql-server-dev-10' for glob 'postgresql*' Note, selecting 'postgresql-plperl-10' for glob 'postgresql*' Note, selecting 'postgresql-9.1-repmgr' for glob 'postgresql*' Note, selecting 'postgresql-10-similarity' for glob 'postgresql*' Note, selecting 'postgresql-client-10' for glob 'postgresql*' Note, selecting 'postgresql-plpython-10' for glob 'postgresql*' Note, selecting 'postgresql-plpython3-10' for glob 'postgresql*' Note, selecting 'postgresql-client-common' for glob 'postgresql*' Note, selecting 'postgresql-10-python-multicorn' for glob 'postgresql*' Note, selecting 'postgresql-10' instead of 'postgresql-contrib-10' Package 'postgresql-7.4' is not installed, so not removed Package 'postgresql-8.0' is not installed, so not removed Package 'postgresql-9.1' is not installed, so not removed Note, selecting 'postgresql-plperl-10' instead of 'postgresql-plperl' Note, selecting 'postgresql-plpython-10' instead of 'postgresql-plpython' Note, selecting 'postgresql-plpython3-10' instead of 'postgresql-plpython3' Note, selecting 'postgresql-pltcl-10' instead of 'postgresql-pltcl' Package 'postgresql-9.3' is not installed, so not removed Package 'postgresql-9.4' is not installed, so not removed Package 'postgresql-9.5' is not installed, so not removed Package 'postgresql-9.6' is not installed, so not removed Note, selecting 'postgresql-10-plr' instead of 'postgresql-plr' Package 'postgresql-server' is not installed, so not removed Package 'postgresql-postgis-java' is not installed, so not removed Note, selecting 'postgresql-10-pgtap' instead of 'postgresql-pgtap' Note, selecting 'postgresql-10-plv8' instead of 'postgresql-plv8' Package 'postgresql-10-postgis-2.2-scripts' is not installed, so not removed Package 'postgresql-10-postgis-2.3-scripts' is not installed, so not removed Note, selecting 'postgresql-10-python-multicorn' instead of 'postgresql-python-multicorn' Note, selecting 'postgresql-10-python3-multicorn' instead of 'postgresql-python3-multicorn' Note, selecting 'postgresql-10-slony1-2' instead of 'postgresql-10-slony1' Note, selecting 'postgresql-pgsphere' instead of 'postgresql-10-pgsphere' Note, selecting 'postgresql-q3c' instead of 'postgresql-10-q3c' Package 'postgresql-9.6-repmgr' is not installed, so not removed Package 'postgresql-9.5-repmgr' is not installed, so not removed Package 'postgresql-9.4-repmgr' is not installed, so not removed Package 'postgresql-9.3-repmgr' is not installed, so not removed Package 'postgresql-9.2-repmgr' is not installed, so not removed Package 'postgresql-9.1-repmgr' is not installed, so not removed Package 'postgresql-9.0-repmgr' is not installed, so not removed Package 'postgresql-10-amcheck' is not installed, so not removed Package 'postgresql-10-asn1oid' is not installed, so not removed Package 'postgresql-10-bgw-replstatus' is not installed, so not removed Package 'postgresql-10-citus' is not installed, so not removed Package 'postgresql-10-cron' is not installed, so not removed Package 'postgresql-10-debversion' is not installed, so not removed Package 'postgresql-10-dirtyread' is not installed, so not removed Package 'postgresql-10-ip4r' is not installed, so not removed Package 'postgresql-10-jsquery' is not installed, so not removed Package 'postgresql-10-mimeo' is not installed, so not removed Package 'postgresql-10-mysql-fdw' is not installed, so not removed Package 'postgresql-10-ogr-fdw' is not installed, so not removed Package 'postgresql-10-orafce' is not installed, so not removed Package 'postgresql-10-partman' is not installed, so not removed Package 'postgresql-10-pgaudit' is not installed, so not removed Package 'postgresql-10-pgextwlist' is not installed, so not removed Package 'postgresql-10-pgfincore' is not installed, so not removed Package 'postgresql-10-pglogical' is not installed, so not removed Package 'postgresql-10-pgmemcache' is not installed, so not removed Package 'postgresql-10-pgmp' is not installed, so not removed Package 'postgresql-10-pgrouting' is not installed, so not removed Package 'postgresql-10-pgrouting-doc' is not installed, so not removed Package 'postgresql-10-pgrouting-scripts' is not installed, so not removed Package 'postgresql-10-pgtap' is not installed, so not removed Package 'postgresql-10-pldebugger' is not installed, so not removed Package 'postgresql-10-pllua' is not installed, so not removed Package 'postgresql-10-plproxy' is not installed, so not removed Package 'postgresql-10-plr' is not installed, so not removed Package 'postgresql-10-plsh' is not installed, so not removed Package 'postgresql-10-plv8' is not installed, so not removed Package 'postgresql-10-postgis-2.4' is not installed, so not removed Package 'postgresql-10-postgis-2.4-scripts' is not installed, so not removed Package 'postgresql-10-postgis-scripts' is not installed, so not removed Package 'postgresql-10-powa' is not installed, so not removed Package 'postgresql-10-prefix' is not installed, so not removed Package 'postgresql-10-preprepare' is not installed, so not removed Package 'postgresql-10-prioritize' is not installed, so not removed Package 'postgresql-10-python-multicorn' is not installed, so not removed Package 'postgresql-10-python3-multicorn' is not installed, so not removed Package 'postgresql-10-repack' is not installed, so not removed Package 'postgresql-10-repmgr' is not installed, so not removed Package 'postgresql-10-rum' is not installed, so not removed Package 'postgresql-10-similarity' is not installed, so not removed Package 'postgresql-10-slony1-2' is not installed, so not removed Package 'postgresql-10-unit' is not installed, so not removed Package 'postgresql-autodoc' is not installed, so not removed Package 'postgresql-comparator' is not installed, so not removed Package 'postgresql-filedump' is not installed, so not removed Package 'postgresql-hll' is not installed, so not removed Package 'postgresql-pgsphere' is not installed, so not removed Package 'postgresql-q3c' is not installed, so not removed Package 'postgresql-contrib' is not installed, so not removed Package 'postgresql-doc' is not installed, so not removed Package 'postgresql-doc-10' is not installed, so not removed Package 'postgresql-plperl-10' is not installed, so not removed Package 'postgresql-plpython-10' is not installed, so not removed Package 'postgresql-plpython3-10' is not installed, so not removed Package 'postgresql-pltcl-10' is not installed, so not removed Package 'postgresql-10-pgq-node' is not installed, so not removed Package 'postgresql-10-pgq3' is not installed, so not removed Package 'postgresql-all' is not installed, so not removed The following packages were automatically installed and are no longer required: cron dctrl-tools distro-info-data iproute2 libatm1 libmnl0 libpq-dev libxslt1.1 libxtables12 logrotate lsb-release ssl-cert sysstat Use 'apt autoremove' to remove them. The following packages will be REMOVED: postgresql* postgresql-10* postgresql-client* postgresql-client-10* postgresql-client-common* postgresql-common* postgresql-server-dev-10* postgresql-server-dev-all* 0 upgraded, 0 newly installed, 8 to remove and 169 not upgraded. After this operation, 26.5 MB disk space will be freed. Do you want to continue? [Y/n] Y (Reading database ... 45376 files and directories currently installed.) Removing postgresql (10+190ubuntu0.1) ... Removing postgresql-10 (10.23-0ubuntu0.18.04.2) ... invoke-rc.d: could not determine current runlevel invoke-rc.d: policy-rc.d denied execution of stop. Removing postgresql-client (10+190ubuntu0.1) ... Removing postgresql-client-10 (10.23-0ubuntu0.18.04.2) ... Removing postgresql-server-dev-all (190ubuntu0.1) ... Removing postgresql-server-dev-10 (10.23-0ubuntu0.18.04.2) ... Removing postgresql-common (190ubuntu0.1) ... invoke-rc.d: could not determine current runlevel invoke-rc.d: policy-rc.d denied execution of stop. Removing 'diversion of /usr/bin/pg_config to /usr/bin/pg_config.libpq-dev by postgresql-common' Removing postgresql-client-common (190ubuntu0.1) ... (Reading database ... 43895 files and directories currently installed.) Purging configuration files for postgresql-10 (10.23-0ubuntu0.18.04.2) ... Dropping cluster main... Purging configuration files for postgresql-client-common (190ubuntu0.1) ... dpkg: warning: while removing postgresql-client-common, directory '/etc/postgresql-common' not empty so not removed Purging configuration files for postgresql-common (190ubuntu0.1) ... dpkg: warning: while removing postgresql-common, directory '/var/lib/postgresql' not empty so not removed root@autodl-container-616f40a3b3-41cb82d9:~#
檢查并刪除殘留文件
卸載后,你可能還想檢查并手動刪除PostgreSQL可能留下的任何殘留文件或目錄。
這通常包括/etc/postgresql/(配置文件)和/var/lib/postgresql/(數(shù)據(jù)文件)目錄。
例:
root@autodl-container-616f40a3b3-41cb82d9:~# ls -l /etc/postgresql-common ls: cannot access '/etc/postgresql-common': No such file or directory root@autodl-container-616f40a3b3-41cb82d9:~# ls -l /var/lib/postgresql total 31864 -rw------- 1 postgres postgres 2812 Sep 28 08:56 logfile drwxrwxr-x 7 postgres postgres 111 Sep 26 22:16 pgsql16 drwxrwxr-x 7 postgres postgres 4096 Sep 27 21:46 pgvector drwxrwxr-x 6 postgres postgres 4096 Sep 26 21:30 postgresql-16.3 -rw-rw-r-- 1 postgres postgres 32616059 May 7 04:31 postgresql-16.3.tar.gz root@autodl-container-616f40a3b3-41cb82d9:~#
但是,由于–purge選項已經(jīng)嘗試刪除了配置文件,這些目錄可能已經(jīng)被清空或不存在了。
驗證卸載
可以使用dpkg -l | grep postgresql命令再次檢查,以確保沒有留下任何與PostgreSQL相關(guān)的包。
如果命令沒有返回任何內(nèi)容,說明PostgreSQL已經(jīng)被成功卸載。
root@autodl-container-616f40a3b3-41cb82d9:~# dpkg -l | grep postgresql root@autodl-container-616f40a3b3-41cb82d9:~#
按照上述步驟操作后,你應(yīng)該已經(jīng)成功卸載了通過apt-get安裝的PostgreSQL 10.23版本。
到此這篇關(guān)于卸載apt-get安裝的PostgreSQL版本實現(xiàn)的文章就介紹到這了,更多相關(guān)PostgreSQL apt-get卸載內(nèi)容請搜索腳本之家以前的文章或繼續(xù)瀏覽下面的相關(guān)文章希望大家以后多多支持腳本之家!
相關(guān)文章
PostgreSQL教程(六):函數(shù)和操作符詳解(2)
這篇文章主要介紹了PostgreSQL教程(六):函數(shù)和操作符詳解(2),本文講解了模式匹配、數(shù)據(jù)類型格式化函數(shù)、時間/日期函數(shù)和操作符等內(nèi)容,需要的朋友可以參考下2015-05-05
PostgreSQL數(shù)據(jù)庫中Sequence的使用方法詳解
在 PostgreSQL 數(shù)據(jù)庫中,Sequence 是一種特殊的表對象,主要用于生成按順序遞增或遞減的數(shù)字序列,通常用于需要唯一標(biāo)識符的場景,例如自增 ID,以下是如何在 PostgreSQL 中使用 Sequence 的詳細(xì)步驟,需要的朋友可以參考下2024-11-11
PostgreSQL實現(xiàn)跨數(shù)據(jù)庫授權(quán)查詢的詳細(xì)步驟
在PostgreSQL中,由于一個數(shù)據(jù)庫實例下的不同數(shù)據(jù)庫在邏輯上是隔離的,你不能像在同一個數(shù)據(jù)庫內(nèi)跨模式那樣直接查詢,因此,你需要分兩步走:先授權(quán),后查詢,所以本文給大家介紹了PostgreSQL實現(xiàn)跨數(shù)據(jù)庫授權(quán)查詢的詳細(xì)步驟,需要的朋友可以參考下2025-10-10
PostgreSQL數(shù)據(jù)庫備份的幾種實現(xiàn)方法
本文主要介紹了PostgreSQL數(shù)據(jù)庫備份的幾種實現(xiàn)方法,包括pg_dump和pg_dumpall是PostgreSQL備份工具,前者備份單數(shù)據(jù)庫,后者備份整個集群,感興趣的可以了解一下2025-06-06
postgresql限制某個用戶僅連接某一個數(shù)據(jù)庫的操作
這篇文章主要介紹了postgresql限制某個用戶僅連接某一個數(shù)據(jù)庫的操作,具有很好的參考價值,希望對大家有所幫助。一起跟隨小編過來看看吧2021-01-01

