How to remove Postgres from my installation?

The simplest way to do this is to open a terminal and type:

sudo apt-get --purge remove postgresql postgresql-*

This will also prompt you to remove that software that depends on Postgres, which in this case it appears you would like to do.
I do not personally run 9.10 or Postgres, so it is possible that Postgres installs itself in several parts. In that case, a simple:

dpkg -l | grep postgres

Will get you the list of those packages that Postgres installed. Then, just use the same "apt-get --purge remove ...." command but instead of just postgresql, type each package name, separated by spaces, like:

sudo apt-get --purge remove postgresql postgresql-doc postgresql-common

This is dependent on the list of packages installed, of course.


Steps that worked for me on Ubuntu 8.04.2 to remove postgres 8.3

  1. List All Postgres related packages

    dpkg -l | grep postgres
    
    ii  postgresql                            8.3.17-0ubuntu0.8.04.1           object-relational SQL database (latest versi
    ii  postgresql-8.3                        8.3.9-0ubuntu8.04                object-relational SQL database, version 8.3
    ii  postgresql-client                     8.3.9-0ubuntu8.04                front-end programs for PostgreSQL (latest ve
    ii  postgresql-client-8.3                 8.3.9-0ubuntu8.04                front-end programs for PostgreSQL 8.3
    ii  postgresql-client-common              87ubuntu2                        manager for multiple PostgreSQL client versi
    ii  postgresql-common                     87ubuntu2                        PostgreSQL database-cluster manager
    ii  postgresql-contrib                    8.3.9-0ubuntu8.04                additional facilities for PostgreSQL (latest
    ii  postgresql-contrib-8.3                8.3.9-0ubuntu8.04                additional facilities for PostgreSQL
    
  2. Remove all above listed

    sudo apt-get --purge remove postgresql postgresql-8.3  postgresql-client  postgresql-client-8.3 postgresql-client-common postgresql-common  postgresql-contrib postgresql-contrib-8.3
    
  3. Remove the following folders

    sudo rm -rf /var/lib/postgresql/
    sudo rm -rf /var/log/postgresql/
    sudo rm -rf /etc/postgresql/
    
  4. Remove the postgres user:

    sudo deluser postgres
    

One command to completely remove postgresql in terminal is sudo apt-get --purge remove postgresql\*. Please note that this command will remove postgresql and all it's compenents.


Follow the commands:

  • sudo apt-get --purge remove postgresql

List all postgres related packages:

  • dpkg -l | grep postgres

remove all the above listed packages using the command :

  • apt-get --purge remove package1 package2 ..

Confirm all the files and folders related to postgres/postgresql are deleted using the command :

  • whereis postgres
  • whereis postgresql

Remove all the files and folders listed using rm command.

Delete the user postgres using the command :

  • userdel -f postgres

happy coding :)