How to install PostgreSQL on Debian 9 Stretch

Debian Tutorial – Hello everyone, today we will learn how to install PostgreSQL on Debian 9 Stretch. PostgreSQL is a well known, powerful relational database server. If you are new to PostgreSQL, you can read more about this database server from this link. PostgreSQL can be installed on most Linux distribution. Debian users can install this software via package manager.

Steps to install PostgreSQL on Debian 9 Stretch

Step 1. Update your system

Before we install, we need to make sure that our system is up to date.

apt update && apt upgrade

Step 2. Install PostgreSQL

Now, execute this command to install

apt install postgresql postgresql-client

Output:

root@debian:/home/dhani# apt install postgresql
Reading package lists... Done
Building dependency tree       
Reading state information... Done
The following additional packages will be installed:
  libpq5 libsensors4 postgresql-9.6 postgresql-client-9.6 postgresql-client-common postgresql-common
  postgresql-contrib-9.6 sysstat
Suggested packages:
  lm-sensors postgresql-doc locales-all postgresql-doc-9.6 libdbd-pg-perl isag
The following NEW packages will be installed:
  libpq5 libsensors4 postgresql postgresql-9.6 postgresql-client-9.6 postgresql-client-common postgresql-common
  postgresql-contrib-9.6 sysstat
0 upgraded, 9 newly installed, 0 to remove and 0 not upgraded.
Need to get 6,745 kB of archives.
After this operation, 30.8 MB of additional disk space will be used.
Do you want to continue? [Y/n]

Now check if the server is active and working properly

systemctl status postgresql

Output

root@debian:/home/dhani# systemctl status postgres
Unit postgres.service could not be found.
root@debian:/home/dhani# systemctl status postgresql
● postgresql.service - PostgreSQL RDBMS
   Loaded: loaded (/lib/systemd/system/postgresql.service; enabled; vendor preset: enabled)
   Active: active (exited) since Sun 2017-09-17 21:42:01 WITA; 4min 0s ago
 Main PID: 28564 (code=exited, status=0/SUCCESS)
      CPU: 1ms
   CGroup: /system.slice/postgresql.service

Sep 17 21:42:01 debian systemd[1]: Starting PostgreSQL RDBMS...
Sep 17 21:42:01 debian systemd[1]: Started PostgreSQL RDBMS.

At this point our new PostgreSQL Server is up and running. Thank you for reading this how to install PostgreSQL on Debian 9 Stretch.

Be the first to comment

Leave a Reply

Your email address will not be published.


*