xxjjnn
xxjjnn

Reputation: 15239

psql version different depending on how you check it

The system says it has psql version 13 in 3 places, but seems to be version 11:

The three places:

> psql --version
psql (PostgreSQL) 13.1 (Ubuntu 13.1-1.pgdg20.04+1)

> pg_config --version
PostgreSQL 13.1 (Ubuntu 13.1-1.pgdg20.04+1)

> psql -U postgres               
psql (13.1 (Ubuntu 13.1-1.pgdg20.04+1), server 11.10 (Ubuntu 11.10-1.pgdg20.04+1))
Type "help" for help.

postgres=#

In postgres if I run SELECT version(); it says 11:

postgres=# SELECT version();
                                                              version                                                               
------------------------------------------------------------------------------------------------------------------------------------
 PostgreSQL 11.10 (Ubuntu 11.10-1.pgdg20.04+1) on x86_64-pc-linux-gnu, compiled by gcc (Ubuntu 9.3.0-17ubuntu1~20.04) 9.3.0, 64-bit
(1 row)

I was getting this error, but changes to /etc/postgresql/13/main/pg_hba.conf (13) had no effect on psql command, whereas changes to /etc/postgresql/11/main/pg_hba.conf (11) did.

What is going on? Is there some strange nuance of psql?

Upvotes: 1

Views: 2235

Answers (1)

user330315
user330315

Reputation:

Apparently you have two Postgres versions installed (13 and 11).

The PATH variable contains the binaries (psql, pg_config) for version 13, but version 11 is running on the default port 5432. Which also explains why you need to change pg_hba.conf for the version 11 to see a difference in the connection behaviour.

If you want to connect to the 13 instance, you need to provide the port for that. Try e.g. psql -p 5433 -U postgres - typically a second installation defaults to the next higher port number

Upvotes: 2

Related Questions