2

I have PostgreSQL installed in my Linux machine, I'm following a old YT tutorial for work and the instructor is using PostgreSQL 11. I have already used the following command:

sudo apt-get -y install postgresql-11

To install PostgreSQL 11 in my machine, how do I connect to this specific version and not version 12?

Jeremy
  • 1,447
  • 20
  • 40
  • Just use 12. It can do anything 11 can, identically in most cases. I would doubt there is anything in your tutorial will have any change. If you have issues just post a question and indicate the difference in Postgres version. BTW I use v12 locally yet deploy to v9.5 and v10. Have never had a problem. – Belayer Aug 27 '20 at 03:51
  • TypeORM had no support for Postgress 12, I was already using Postgress 12 until now but I recently ran into major problems. – Jeremy Aug 27 '20 at 03:59

2 Answers2

2

Postgress configuration files are located at:

/etc/postgresql/##/main/postgresql.conf

Use your favorite code editor and navigate to the CONNECTIONS AND AUTHENTICATION this will reveal at which port the Postgress database is listening. Connect to you desired version using the -p flag. For me Postgres 11 is using port 5433 and Postgres 12 is using 5432.

psql -h 5433 postgress

Check your version using

SHOW version();

Expected output

                                                          version                                                           
----------------------------------------------------------------------------------------------------------------------------
 PostgreSQL 11.9 (Ubuntu 11.9-1.pgdg20.04+1) on x86_64-pc-linux-gnu, compiled by gcc (Ubuntu 9.3.0-10ubuntu2) 9.3.0, 64-bit
(1 row)
Jeremy
  • 1,447
  • 20
  • 40
2

The 2nd installed version is probably running on port 5433 rather than 5432. But rather than guessing, you can run pg_lsclusters and see. Then specify that port number whereever you need to connect.

jjanes
  • 37,812
  • 5
  • 27
  • 34