psql command "Error: PostgreSQL version 12 is not installed"
I have installed PostgreSQL 11 but for some reason when I type psql
in the terminal I get PostgreSQL version 12 is not installed
error
Recently I uninstalled a PostgreSQL server so I think I didn't do it well
How could I get psql command exec version 11 instead of 12
Solution 1:
I've reproduced your case and here's how I resolved it:
Use sudo apt purge postgresql-12
answering Yes
if you want to remove it completely:
┌───────────────────────────────────────────────────────────────────┤ Configuring postgresql-11 ├────────────────────────────────────────────────────────────────────┐
│ │
│ Removing the PostgreSQL server package will leave existing database clusters intact, i.e. their configuration, data, and log directories will not be removed. On │
│ purging the package, the directories can optionally be removed. │
│ │
│ Remove PostgreSQL directories when package is purged? │
│ │
│ <Yes> <No> │
│ │
└────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┘
After this:
sudo psql --version
psql (PostgreSQL) 11.7 (Ubuntu 11.7-2.pgdg19.10+1)
Solution 2:
I had installed postgresql-13
then "rolled back" to postgresql-client-12
after an OS upgrade. I found a zombie /etc/postgresql/13
directory and removed it and I can now successfully execute psql
Solution 3:
Just move the /etc/postgresql/12
directory somewhere else and only leave the version that pg_dump
is installed on that directory.
I found it out by issuing strace pg_dump|& grep open
command