×


Install PostgreSQL on Debian 10 - Step by step process to do it ?

PostgreSQL is an open-source relational database management system (RDBMS) emphasizing extensibility and SQL compliance.

It is the default database for macOS Server and is also available for Windows, Linux, FreeBSD, and OpenBSD.

PostgreSQL is easy-to-use with a full stack of RDBMS database features and capabilities for handling data. It can be easily installed on Linux environments. 

Here at LinuxAPT, as part of our Server Management Services, we regularly help our Customers to perform Software Installation tasks.

In this context, we shall look into how to install PostgreSQL on Debian 10.


Steps to follow to install PostgreSQL on Debian 10 ?

To get PostgreSQL installed on Debian 10 system, you have to perform all the steps outlined below.


1. Update your Debian 10 System:

Since we are going to install a new database management system (DBMS) on our Debian 10 system that is why we have to update our system's cache first with the help of the following command:

$ sudo apt update 

Once our Debian 10 system will finish the update, it will display the number of packages to be upgraded.


2. Install PostgreSQL on your Debian 10 System:

After updating our Debian 10 system, we are good to go with the installation of PostgreSQL on it. 

It can be installed by running the following command:

$ sudo apt install postgresql postgresql-contrib

The PostgreSQL DBMS will take a few minutes to install on Debian 10 along with all of its required packages and dependencies.

Once it is installed, your terminal will allow you to proceed further.


3. Check the Version of the Installed PostgreSQL on your Debian 10 System:

After installing PostgreSQL on Debian 10, you can check out its version by executing the following command:

$ psql --version


4. Start the PostgreSQL Service on Debian 10:

In some Linux distributions, the PostgreSQL service starts automatically, however, you can always start it manually by issuing the following command in your Debian 10 system:

$ sudo systemctl start postgresql

If the PostgreSQL service is started without any potential issues, then you will not face any error messages.


5. Check the Status of the PostgreSQL Service on Debian 10:

After starting the PostgreSQL service on your Debian 10 system, you can check its status by running the following command:

$ sudo systemctl status postgresql


6. Check whether PostgreSQL is Accepting New Connections or not:

Additionally, you can also check whether your PostgreSQL DBMS is accepting new connections or not. 

This can be done by running the following command:

$ pg_isready

If your PostgreSQL service is ready, then it will display the "accepting connections" status.


7. Switch to the Default User Account of PostgreSQL in Debian 10:

Now the next step is to access the PostgreSQL shell for which we have to switch to its default user account. When you install the PostgreSQL DBMS, a user account named "postgres" is created by default. 

We can switch to that account by running the following command:

$ sudo su – postgres

When you run this command, you will notice that the root user will switch to the default PostgreSQL user on the terminal.


8. Enter the PostgreSQL Shell in Debian 10:

Once you have switched to the default PostgreSQL user account in Debian 10, you can easily enter its shell by issuing the following command in the terminal:

$ psql

This command will display the PostgreSQL shell.


How to uninstall PostgreSQL from Debian 10 ?

Whenever you need to remove PostgreSQL DBMS from Debian 10, as well as its configuration files, then you can execute the following command:

$ sudo apt-get --purge remove postgresql\*


Now when the PostgreSQL DBMS is removed successfully from your Debian 10 system, then you would no longer need those packages and dependencies that were installed automatically with this DBMS. 

To get rid of all such packages and dependencies, you can run the following command in the terminal:

$ sudo apt-get autoremove

This command will remove all the unused and irrelevant packages and dependencies from your Debian 10 system.


[Need urgent assistance to install Missing Packages on your Debian Linux Server? We are available to help you today. ]


Conclusion

This article will guide you on how you can install PostgreSQL #DBMS on your Debian 10 system. Also, we also shared with you the method with which you can remove the PostgreSQL DBMS from your #Debian 10 system.

#PostgreSQL supports transaction s, subselects, trigger s, view s, foreign key referential integrity, and sophisticated locking.


pgAdmin is the de facto GUI tool for PostgreSQL, and the first tool anyone would use for PostgreSQL. It supports all PostgreSQL operations and features while being free and open-source. With pgAdmin you can Create, view and edit on all common PostgreSQL objects.

#PgAdmin is graphical user interface administration tool for PostgreSQL. It does not include a PostgreSQL database server.


To install PostgreSQL 9.5 on #Ubuntu:

1. sudo apt-get update.

2. sudo apt-get install postgresql postgresql-contrib.

3. sudo -u postgres psql.

4. # Replace xxxxxxx with your own password ALTER USER postgres WITH ENCRYPTED PASSWORD 'xxxxxxx';

5. # Feel free to replace nano with an editor of your choice sudo nano /etc/postgresql/9.5/main/pg_hba.conf.


ANALYZE in #Postgres collects statistics about the contents of tables in the database, and stores the results in the pg_statistic system catalog. Subsequently, the query planner uses these statistics to help determine the most efficient execution plans for queries.