How to Check Version of Postgres
This article shows how to check the version of Postgres.
Check the Postgres Version in Windows
C:\Users\Admin>psql --version
psql (PostgreSQL) 14.0
C:\Users\Admin>postgres --version
postgres (PostgreSQL) 14.0
Here it shows the version as 14.0.
There’s another method from the Postgres console. The command is:
postgres=# SELECT version();
version
------------------------------------------------------------
PostgreSQL 14.0, compiled by Visual C++ build 1914, 64-bit
(1 row)
postgres=#
Sometimes in Windows, there might be some error, such as that the Postgres psql
command is not recognized in the Windows environment.
This means the path of the Postgres or psql
is not present in the environment variable.
During installation, the setup wizard asks the user if he/she wants to add it to the environment variable or not. If you miss that part, then follow these steps.
-
Search
Edit the System Environment Variables
and press Enter. -
Click the button
Environment Variables
from the bottom right corner. -
Select
path
from theUser Variables for Admin
list. -
Click
edit
. -
Copy the path of the
bin
folder of the Postgres installation directory. -
Click
New
and paste thepath
. -
Select
OK
and after that clickApply
.
Check the Postgres Version in Linux
$ Postgres -version
Or,
$ postgres -V
It can happen that you are getting an error, Command Postgres not found
. It means that the ELF
file for Postgres is not found.
You can locate the bin folder then type the full command with the full path. This will work because the bin folder always contains the binary to run the Postgres
command.
Most probable path is something like this /usr/lib/postgressql/14/bin/Postgres
.
$ locate bin/postgres
/usr/lib/postgressql/14/bin/postgres
Now, run the following command:
$ /usr/lib/postgressql/14/bin/postgres -V
To learn more about Postgres documentation, you can visit here.