Linux check postgresql version

Как проверить версию PostgreSQL

PostgreSQL, часто известный просто как Postgres, представляет собой универсальную объектно-реляционную систему управления базами данных с открытым исходным кодом.

В некоторых ситуациях важно знать, какая версия сервера PostgreSQL установлена и запущена в вашей системе. Например, если вы устанавливаете приложение, для которого требуется определенная версия PostgreSQL, вам необходимо узнать версию вашего сервера PostgreSQL.

В этой статье мы объясним, как узнать, какая версия сервера PostgreSQL работает в вашей системе.

Управление версиями PostgreSQL

Версии выпусков PostgreSQL контролируются по следующей схеме:

Например, в PostgreSQL 12.1 12 — это основная версия, а 1 — дополнительная версия.

  • MAJOR — Начиная с PostgreSQL 10, каждый новый основной выпуск увеличивает MAJOR часть версии на единицу, например, 10, 11 или 12. До PostgreSQL 10 основные версии представлялись десятичным числом, например 9.0 или 9.6.
  • MINOR — второстепенный номер выпуска — это последняя часть номера версии. Например, 11.4 и 11.6 являются второстепенными версиями, которые являются частью PostgreSQL версии 11, а 9.6.15 и 9.6.16 являются частью PostgreSQL версии 9.6.

Основные выпуски PostgreSQL с новыми функциями обычно выпускаются один раз в год. Каждый основной выпуск поддерживается в течение 5 лет.

Использование командной строки

Чтобы узнать, какая версия PostgreSQL работает в вашей системе, вызовите команду postgres с параметром —version или -V :

Команда выведет версию PostgreSQL:

В этом примере версия сервера PostgreSQL — 10.6 .

Если двоичный файл postgres отсутствует в системном PATH , вы получите сообщение об ошибке «postgres: команда не найдена». Обычно это происходит, когда пакет PostgreSQL не установлен из стандартных репозиториев дистрибутива.

Вы можете найти путь к двоичному файлу с помощью команды locate или find :

sudo find /usr -wholename '*/bin/postgres'
sudo updatedblocate bin/postgres

Результат должен выглядеть примерно так:

/usr/lib/postgresql/9.6/bin/postgres 

Найдя путь к двоичному файлу, вы можете использовать его для получения версии сервера PostgreSQL:

/usr/lib/postgresql/9.6/bin/postgres -V

Версию клиентской утилиты PostgreSQL, psql можно найти с помощью следующей команды:

Результат будет выглядеть примерно так:

psql — это интерактивная утилита командной строки, которая позволяет вам взаимодействовать с сервером PostgreSQL.

Использование оболочки SQL

Другой способ определить версию сервера PostgreSQL — войти в запрос SQL сервера и использовать оператор SQL для печати версии.

Вы можете получить доступ к оболочке PostgreSQL с помощью клиента с графическим интерфейсом, например pgAdmin, или с помощью psql :

Следующий оператор отображает версию сервера PostgreSQL вместе с информацией о сборке:

 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) 

Если вы хотите получить только номер версии сервера PostgreSQL, используйте следующий запрос:

 server_version ---------------- 10.6 (1 row) 

Выводы

В этой статье мы показали несколько различных вариантов того, как найти версию сервера PostgreSQL, работающую в вашей системе.

Читайте также:  Linux command to display all files

Не стесняйтесь оставлять комментарии, если у вас есть вопросы.

Источник

How to Check Your PostgreSQL Version

New versions of PostgreSQL are released at regular intervals. Major releases are scheduled yearly and focus on improving key features and fixing known bugs. Minor releases are available approximately every three months and aim to resolve ongoing security concerns.

You might want to check if you have the latest security patch, or if the new software you want to implement is compatible with your PostgreSQL version.

This tutorial shows you how to check your PostgreSQL version using a few short commands.

Title with PostgreSQL logo and versioning symbol.

Note: Have you considered installing SQL Workbench for Postgres? It’s a great tool for managing different database systems.

Check PostgreSQL Version from Command Line

Access your terminal and enter the following command to check your PostgreSQL version:

The version number is displayed in your terminal window. Another way to check your PostgreSQL version is to use the -V option:

These two commands work with installations initiated from official repositories. They might not be applicable for installations originating from third-party sources. Instead, you might receive the “Command ‘postgres’ not found” message.

How to Solve the “Command ‘postgres’ not found” Error

To solve the “Command ‘postgres’ not found” issue, locate the PostgreSQL binary folder. Enter the following command to locate the correct postgres path:

The path to your binary folder is now displayed in your terminal.

Path to postgres binary folder with the locate command.

Type the full path and add the -V option to display the current PostgreSQL server version:

/usr/lib/postgresql/10/bin/postgres -V

In this example, the Postgres version number is 10.12.

The postgres version number is presented in the terminal.

The PostgreSQL Development Group uses a standard MAJOR.MINOR semantic versioning system. In our example, the first section (10) signifies the MAJOR release number. The second part (12), represents the MINOR release number for that major version.

Note: Always update PostgreSQL to the latest available minor version that corresponds to the major version you have installed.

Check Postgres Version from SQL Shell

The version number can also be retrieved directly from the PostgreSQL prompt. Access the PostgreSQL shell prompt by typing the following command:

Type the following SQL statement within the prompt to check the current version:

The resulting output provides the full version and system information for the PostgreSQL server.

The location of the PostgreSQL version found from the Postgres shell.

You can also instruct PostgreSQL to show the value associated with the server_version parameter:

The result displays the current value for server_version.

PostgreSQL version with the SHOW server_version statement.

How to Check psql Client Version

Psql functions as a front-end terminal for PostgreSQL. It’s used to issue queries and display the provided results.

You can use the following command to determine the version of the psql client utility:

Читайте также:  Alt linux установка kde

You’ll notice that the commands used to check the psql client version match the commands used to determine PostgreSQL server version. The -V option works in this instance as well:

The psql version is presented in the terminal.

Pslq version displayed using the psql -V command.

The “Command not found” error can appear in this instance as well. If that is the case, enter the following command to locate the correct path to the psql utility:

The output provides the full path to the psql utility.

Full path to psql utility binary folder,

Use the resulting path and -V option to check the current psql version:

/usr/lib/postgresql/10/bin/psql -V

The resulting output shows you the current psql client version on your system.

Psql version using the full binary path.

Note: If you are in need of more PostgreSQL tutorials, be sure to check out:

The provided commands and SQL statements are the most effective way to determine the PostgreSQL version number. Use them to check the current version of your PostgreSQL database server or psql client utility.

Make sure that your systems are always up to date with the latest available version.

Vladimir is a resident Tech Writer at phoenixNAP. He has more than 7 years of experience in implementing e-commerce and online payment solutions with various global IT services providers. His articles aim to instill a passion for innovative technologies in others by providing practical advice and using an engaging writing style.

Learn how to export a PostgreSQL table to a .csv file. This feature is especially helpful when transferring.

PostgreSQL is an open-source, relational database management system. There are two simple ways of installing.

Explore the differences between the two most widely used database management systems. PostgreSQL and MySQL.

PostgreSQL is an open-source relational database management system. In this tutorial learn how to connect.

Источник

How to Check PostgreSQL Version

A C-based open-source database management system, PostgreSQL, was developed in 1996 by the University of California, Berkeley. PostgreSQL keeps updating the database version at regular time intervals. Its primary edition is released once a year and focuses on fixing known bugs, adding new features, and improving them. It is essential to know the version of PostgreSQL installed on your system, both as a database administrator and system administrator. Its minor version comes at least every three months to address ongoing security concerns.

Major Version of PostgreSQL

Earlier, its major version was represented as a decimal number, e.g., 9.6 or 9.0. After PostgreSQL 10, the central part of the version increased by one number for major release versions, e.g., 10, 11, 12, etc.

Minor Version of PostgreSQL

The last part number of the version shows the minor release number. E.g., 10.4 or 10.6 are minor versions of PostgreSQL version 10. In the past, Version 13.3 of PostgreSQL has been available for installation. We will explore different methods to check PostgreSQL’s version in this tutorial.

How to Check PostgreSQL Version

You can check the PostgreSQL version in several ways. Here, we will understand all the methods and see how you can check the version of PostgreSQL in your system.

Читайте также:  Установка linux через wds

Check the PostgreSQL Version Using Command-Line

You can check the current PostgreSQL version running on your system with the help of the command line. You can do this by accessing the terminal and running the following command:

You can run any of the previous commands and check the PostgreSQL version. Both the commands will provide you with the same output.

You get an error of “Postgres: command not found” if the Postgres binary is not present in the path to the file system. Let us troubleshoot this problem by searching the PostgreSQL binary directory. Run the following command in a terminal window:

With this command, you can see the full path to the PostgreSQL binary folder in your terminal. Type the full path to find out what version of PostgreSQL you have:

Both these commands will provide you with the same output.

Check the PostgreSQL Version Using SQL Shell

You can retrieve the PostgreSQL version through the PostgreSQL prompt. PostgreSQL versions are displayed on the post-login screen after logging into the PostgreSQL server through the terminal.

The server should log into the SQL prompt and get its output by executing the SQL command.

Through Parameters

You can check the PostgreSQL version by preset parameter. Automatic version checking is also possible using the following method:

Through version() Function

By executing version(), you can also determine the PostgreSQL version. You can also check the PostgreSQL version in the automation script.

Check the PostgreSQL Version PSQL Client Version

Apart from being a PostgreSQL client, psql is also a terminal-based command-line utility. Psql gives users access to PostgreSQL databases. Version information for the psql client utility can be found using the following command:

The previous commands will provide you with the same output to use by anyone.

Postgres Version in pgAdmin4

The pgAdmin4 web interface is an excellent way to manage PostgreSQL servers. The web interface shows the Postgres version for the pgAdmin4 users. To find out the PostgreSQL version, follow these steps:

  • Login to the pgAdmin4.
  • Select your Postgres server by expanding servers in the left sidebar.
  • Now, go to the properties tab.
  • The last step is to check the PostgreSQL version under the general section.

Conclusion

In this tutorial, we’ve discussed several methods to check the PostgreSQL version and see how easy it is to check each version. We hope that through this article, you have understood all the methods, and you will have learned to check the version of PostgreSQL by each method. Check the other Linux Hint articles for more tips and tutorials.

About the author

Prateek Jangid

A passionate Linux user for personal and professional reasons, always exploring what is new in the world of Linux and sharing with my readers.

Источник

Оцените статью
Adblock
detector