1

I am running macOS Monterey (version 12.6).

  • psql -V gives me psql (PostgreSQL) 14.6 (Homebrew)

  • postgres -V gives me postgres (PostgreSQL) 14.6 (Homebrew)

  • when I run SELECT version(); inside my psql prompt, I get a postgres version of 8:

    PostgreSQL 8.0.2 on i686-pc-linux-gnu, compiled by GCC gcc (GCC) 3.4.2 20041017 (Red Hat 3.4.2-6.fc3), Redshift 1.0.43931

Question : how can I get postgres version 14 on the psql prompt ? (I need a function that only exists on postgres 9.3 onwards)

2
  • 2
    psql -V gives you the psql version, not the database version you are connected to. Connect to a different database cluster and you might get a different version. Depends on what is installed Commented Nov 29, 2022 at 13:52
  • To change the version, upgrade the database cluster. Commented Nov 29, 2022 at 14:10

1 Answer 1

1

When you run psql command alone, you're actually running

psql --port=5432 --host=localhost --username=postgres --dbname=postgres

These are default values that depend on your environment variables and local config.

If you have multiple PostgreSQL versions installed and launched, they are likely just running on different ports. Regardless of how you launched them, you can search your processes and ports to see if it lists multiple versions and where they're listening:

ps auxwww | grep postgres
sudo lsof -i -P | grep LISTEN

Then just point psql to the other one

psql --port=5433 --host=localhost --username=postgres --dbname=postgres

Running psql -V:

-V
--version
    Print the psql version and exit.

shows you the version of your psql tool that you probably installed with the new version of PostgreSQL, which you probably did without uninstalling/upgrading the old database, or even switching it off. So you're using the new tool bundled with the new db, but still connect to the old db where you run SELECT version();.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.