16

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

Screenshot

Gryu
  • 7,559
  • 9
  • 33
  • 52
Berre
  • 163

4 Answers4

25

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)
Gryu
  • 7,559
  • 9
  • 33
  • 52
  • That's it, Thank you – Berre Apr 14 '20 at 17:15
  • 2
    This seems to be generally valid. I first installed postgresql-12 and then updated to postgresql-13, but it was still using the pg_dump from postgresql-12 (so was refusing to dump reload to my postgresql-13 cluster). Purging 12 worked here also. – AntonOfTheWoods Mar 29 '21 at 02:26
3

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

geogeo
  • 31
1

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

Nmath
  • 12,333
0

The problem is actually being caused by a postgresql port mapping issue in the config files.

By default, Kali comes with postgres 12 (and postgres 13 as of 2020.3), but OpenVAS needs version 13. Kali configures postgres 12 to port 5532 and assigns a higher port (in this case, 5433) for postgres 13. OpenVAS is still looking for 5432 so sees postgres 12 even if 13 is installed.

remove postgresql 12 if you can...if not

A quick solution is to edit the "port = " lines in the

/etc/postgresql/12/main/postgresql.conf port = 5433

and

/etc/postgresql/13/main/postgresql.conf port = 5432

basically swap the port values.

Jay
  • 1