Search code examples
postgresqlnixos

Why does `pg_config --version` give a different version than `select version();` does?


I am attempting to identify what version of postgres server I have installed, and noticed this question on that.

The first answer there says to run SELECT version(); (in postgres), the second answer says to run pg_config --version (in the terminal). Somehow I get different versions when running each of these commands.

In Postgres:

=> select version();
                                      version
------------------------------------------------------------------------------------
 PostgreSQL 9.4.12 on x86_64-unknown-linux-gnu, compiled by gcc (GCC) 5.4.0, 64-bit
(1 row)

In the terminal:

$ pg_config --version
PostgreSQL 9.6.2

Why are different version numbers reported when running these two commands?

My machine is running NixOS.


Solution

  • As Abdel P. suggested, it turned out that I had both a global and a user-level postgres installed.

    I uninstalled the user-level version and now both show version 9.4.12.