23

I have Postgresql 9.1.1 in my Ubuntu 12.04 which got installed due to automatic upgrades and whenever I uninstall it using the command:

sudo apt-get --purge remove postgresql-9.1.1

I get an error saying:

E: Unable to locate package postgresql-9.1.1
E: Couldn't find any package by regex 'postgresql-9.1.1

Can somebody tell me how to uninstall this package completely so that I can install the other lower version - 8.4.7

Braiam
  • 69,112
sanjeeda
  • 311

5 Answers5

29

The version 9.1.1 of PostgerSQL is located in the package postgresql-9.1. So you should remove this package:

sudo apt-get purge postgresql-9.1

The second part of your question is already answered here: How do I downgrade PostgreSQL?

qbi
  • 19,515
13

If you want to uninstall postgresql and any related package, you should use autoremove:

sudo apt-get --purge autoremove postgresql*

This will select any package starting with postgresql and remove any automatic dependency that these packages installed efectivelly removing any version of postgresql. If you only want to remove the client or the server, your bet should be on apt-cache search postgresql | grep client or server.

Braiam
  • 69,112
3

Try:

sudo apt-get --purge remove postgresql-9.1

Also you can install 8.4.7 and stop the server postgresql-9.1.

Seth
  • 59,332
0

I fear the package locations will differ form version to version, so you can uninstall the most from your OS with

sudo apt-get purge postgresql-9.1

but then you will have to find all remaining files and directory with

sudo updatedb && locate *postgres*9*

and remove them manually with

sudo rm -rf <pattern>

For example, I can tell that for postgres 14.7 you should run these commands

sudo apt-get purge postgresql-14.7

sudo rm /var/log/postgresql/postgresql-14-main.log sudo rm -rf /run/postgresql/14* sudo rm -rf /run/systemd/generator/postgresql.service.wants/postgresql@14-main.service sudo rm -rf /usr/lib/postgresql/14/ sudo rm -rf /usr/share/doc/postgresql-14* sudo rm -rf /usr/share/doc/postgresql-client-14* sudo rm -rf /usr/share/lintian/overrides/postgresql-14 sudo rm -rf /usr/share/lintian/overrides/postgresql-client-14 sudo rm -rf /usr/share/postgresql/14/ sudo rm -rf /usr/share/postgresql-common/t/140_pg_config.t sudo rm -rf /var/lib/dpkg/info/postgresql-14* sudo rm -rf /var/lib/dpkg/info/postgresql-client-14* sudo rm -rf /var/lib/postgresql/14/

in the end, check the results with

psql --version
Tms91
  • 595
0

Try:

sudo apt-get --purge remove postgresql
Ads20000
  • 1,983