PostgreSQL, often known simply as Postgres, is an open-source general-purpose object-relational database management system. In this article, we’ll explain how to find PostgreSQL version running on your system.
Knowing what version of the PostgreSQL server is installed and running on your system can be important in some situations. For example, if you are installing an application that requires a specific PostgreSQL version, you’ll need to find out the version of your server.
PostgreSQL releases are versioned using the following scheme:
For example, in PostgreSQL 12.1,
12 is a major version, and
1 is a minor version.
MAJOR– Starting with PostgreSQL 10, each new major release increases the
MAJORpart of the version by one, e.g., 10, 11 or 12. Before PostgreSQL 10, major versions were represented with a decimal number e.g., 9.0 or 9.6.
MINOR– Minor release number is the last part of the version number. For example,
11.6are minor versions that are part of the PostgreSQL version 11, and
9.6.16are part of the PostgreSQL version 9.6.
PostgreSQL major releases with new features are usually delivered once a year. Each major release is supported for 5 years.
You may be interested in learning about how to setup PyroCMS on Linux server.
Find PostgreSQL Version using Command Line
To find out what version of PostgreSQL is running on your system, invoke the
postgres command with the
The command will print the PostgreSQL version:
postgres (PostgreSQL) 10.6
In this example, the version of the PostgreSQL server is
postgres binary is not in system’s PATH, you’ll get an error saying “postgres: command not found”. This usually happens when the PostgreSQL package is not installed from the distribution’s standard repositories.
You can find the path to the binary either with the
sudo find /usr -wholename '*/bin/postgres'
sudo updatedb locate bin/postgres
The output should look something like this:
Once you find the path to the binary, you can use it to get the version of the PostgreSQL server:
The version of the PostgreSQL client utility,
psql can be found using the following command:
The output will look something like this:
postgres (PostgreSQL) 10.6
psql is an interactive command-line utility that allows you to interact with the PostgreSQL server.
Using SQL Shell
Another way to determine the PostgreSQL server version is to log in to the server SQL prompt and use an SQL statement to print out the version.
You can access the PostgreSQL shell using a GUI client like pgAdmin or with
sudo -u postgres psql
The following statement displays the PostgreSQL server version along with the build information:
version PostgreSQL 10.6 on x86_64-redhat-linux-gnu, compiled by gcc (GCC) 8.2.1 20180905 (Red Hat 8.2.1-3), 64-bit (1 row)
If you want to get only the PostgreSQL server version number use the following query:
server_version 10.6 (1 row)
In this article, we have shown several different options about how to find the PostgreSQL version on server running on your system.