• Categories
    Category
  • Categories
    Category
  • News
  • Tutorials
  • Forums
  • Tags
  • Users
Tutorial Comments FAQ Related Articles

How To Install PostgreSQL on Debian 11.3

  • 00:30 lsb_release -a
  • 00:38 ip a
  • 00:47 apt show postgresql
  • 01:06 apt install postgresql postgresql-contrib
  • 01:40 systemctl status postgresql
  • 02:02 systemctl start postgresql
  • 02:19 su – postgres
  • 02:31 psql
  • 02:38 CREATE DATABASE sample_db;
  • 02:47 create user sample_user with encrypted password 'Linuxc#7';
  • 03:15 grant all privileges on database sample_db to sample_user;
  • 03:21 \l
7023

To Install PostgreSQL on Debian 11.3

Introduction

Open-source PostgreSQL is a powerful, object-relational database, known for its reliability and performance. There are a variety of features that make it easier for developers and administrators to deploy data-driven applications.

Installation Procedure:

Step 1: Check the installed OS version by using the below command

linuxhelp@linuxhelp:~$ lsb_release -a
No LSB modules are available.
Distributor ID: Debian
Description:    Debian GNU/Linux 11 (bullseye)
Release:        11
Codename:       bullseye
No LSB modules are available.

Step 2: Check the IP address by using the below command

root@linuxhelp:~# ip a
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1000
    link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
    inet 127.0.0.1/8 scope host lo
       valid_lft forever preferred_lft forever
    inet6 ::1/128 scope host 
       valid_lft forever preferred_lft forever
2: ens33: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP group default qlen 1000
    link/ether 00:0c:29:82:27:2e brd ff:ff:ff:ff:ff:ff
    altname enp2s1
    inet 192.168.6.127/23 brd 192.168.7.255 scope global noprefixroute ens33
       valid_lft forever preferred_lft forever
    inet6 fe80::20bb:a04d:5b24:61a6/64 scope link noprefixroute 

Step 3: Show PostgreSQL the by using the below command

root@linuxhelp:~# apt show postgresql
Package: postgresql
Version: 13+225
Priority: optional
Section: database
Source: postgresql-common (225)
Maintainer: Debian PostgreSQL Maintainers <team+postgresql@tracker.debian.org>
Installed-Size: 69.6 kB
Depends: postgresql-13
Suggests: postgresql-doc
Tag: devel::lang:sql, interface::daemon, network::server, network::service,
 role::metapackage, role::program, suite::postgresql, works-with::db
Download-Size: 64.7 kB
APT-Manual-Installed: yes
APT-Sources: http://deb.debian.org/debian bullseye/main amd64 Packages
Description: object-relational SQL database (supported version)
 This metapackage always depends on the currently supported PostgreSQL
 database server version.
 .
 PostgreSQL is a fully featured object-relational database management
 system.  It supports a large part of the SQL standard and is designed
 to be extensible by users in many aspects.  Some of the features are:
 ACID transactions, foreign keys, views, sequences, subqueries,
 triggers, user-defined types and functions, outer joins, multiversion
 concurrency control.  Graphical user interfaces and bindings for many
 programming languages are available as well.

Step 4: Install PostgreSQL the by using the below command

root@linuxhelp:~# apt install postgresql postgresql-contrib
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
The following additional packages will be installed:
  libpq5 postgresql-13 postgresql-client-13 postgresql-client-common postgresql-common sysstat
Suggested packages:
  postgresql-doc postgresql-doc-13 libjson-perl isag
The following NEW packages will be installed:
  libpq5 postgresql postgresql-13 postgresql-client-13 postgresql-client-common postgresql-common postgresql-contrib
  sysstat
0 upgraded, 8 newly installed, 0 to remove and 263 not upgraded.
Need to get 16.0 MB of archives.
After this operation, 48.9 MB of additional disk space will be used.
Do you want to continue? [Y/n] y
Get:1 http://in.archive.ubuntu.com/ubuntu hirsute-updates/main amd64 libpq5 amd64 13.4-0ubuntu0.21.04.1 [116 kB]
Get:2 http://in.archive.ubuntu.com/ubuntu hirsute/main amd64 postgresql-client-common all 225ubuntu1 [28.7 kB]

Setting up sysstat (12.5.2-2) ...

Creating config file /etc/default/sysstat with new version
update-alternatives: using /usr/bin/sar.sysstat to provide /usr/bin/sar (sar) in auto mode
Created symlink /etc/systemd/system/sysstat.service.wants/sysstat-collect.timer → /lib/systemd/system/sysstat-collect.
timer.
Created symlink /etc/systemd/system/sysstat.service.wants/sysstat-summary.timer → /lib/systemd/system/sysstat-summary.
timer.
Created symlink /etc/systemd/system/multi-user.target.wants/sysstat.service → /lib/systemd/system/sysstat.service.
Setting up postgresql-contrib (13+225ubuntu1) ...
Processing triggers for man-db (2.9.4-2) ...
Processing triggers for libc-bin (2.33-0ubuntu5) ...

Step 5: Check the status PostgreSQL by using the below command

root@linuxhelp:~# systemctl status postgresql
● postgresql.service - PostgreSQL RDBMS
     Loaded: loaded (/lib/systemd/system/postgresql.service; enabled; vendor preset: enabled)
     Active: inactive (dead) since Thu 2022-06-23 05:31:32 IST; 2s ago
    Process: 37489 ExecStart=/bin/true (code=exited, status=0/SUCCESS)
   Main PID: 37489 (code=exited, status=0/SUCCESS)
        CPU: 6ms

Step 6: Start the PostgreSQL by using the below command

root@linuxhelp:~# systemctl start postgresql

Step 7: Logon to PostgreSQL user by using the below command

root@linuxhelp:~# su – postgres

Step 8: Open the PostgreSQL by using the below command

postgres@linuxhelp:~$ psql
psql (13.7 (Debian 13.7-0+deb11u1))
Type "help" for help.

Step 9: Create a database named “sample_db” by using the below command

postgres=# CREATE DATABASE sample_db;
CREATE DATABASE

Step 10: Create a user named “sample_ user” with password by using the below command

postgres=# create user sample_user with encrypted password 'Linuxc#7';
CREATE ROLE

Step 11: Grant all privileges for “sample_ user” user to “sample_db” database by using the below command

postgres=# grant all privileges on database sample_db to sample_user;
GRANT

Step 12: Show the PostgreSQL database by using the below command


postgres-# \l1
                              List of databases
   Name    |  Owner   | Encoding | Collate | Ctype |    Access privileges     
-----------+----------+----------+---------+-------+--------------------------
 postgres  | postgres | UTF8     | en_IN   | en_IN | 
 sample_db | postgres | UTF8     | en_IN   | en_IN | =Tc/postgres            +
           |          |          |         |       | postgres=CTc/postgres   +
           |          |          |         |       | sample_user=CTc/postgres
 template0 | postgres | UTF8     | en_IN   | en_IN | =c/postgres             +
           |          |          |         |       | postgres=CTc/postgres
 template1 | postgres | UTF8     | en_IN   | en_IN | =c/postgres             +
           |          |          |         |       | postgres=CTc/postgres
(4 rows)

Step 13: Exit from the Database by using the below command

postgres=# exit 

Conclusion:

We have reached the end of this article. In this guide, we have walked you through the steps required to Install PostgreSQL on Debian 11.3.Your feedback is much welcome.

Tags:
connor
Author: 

Comments ( 0 )

No comments available

Add a comment

Frequently asked questions ( 5 )

Q

How to delete the Postgres database?

A

Use the DROP DATABASE command to delete a not-needed database.

Q

How to list Postgres users?

A

Use \du or \du+ COMMAND to list Postgres users.

Q

Differentiate PostgreSQL and MySQL?

A

Postgres is an object-relational database, while MySQL is a purely relational database.

Q

What is the default Postgres user?

A

The default Postgres user is "postgres"

Q

How do I log in as a Postgres user?

A

Log on to Postgres user by using the command "sudo -u postgres"

Related Tutorials in How To Install PostgreSQL on Debian 11.3

Related Tutorials in How To Install PostgreSQL on Debian 11.3

How to install Gparted on Debian 9.0
How to install Gparted on Debian 9.0
Sep 13, 2017
Installation SSL Certificate on Ubuntu/Linuxmint/Debian to Secure Apache
Installation SSL Certificate on Ubuntu/Linuxmint/Debian to Secure Apache
Sep 19, 2018
How to install Xrdp Server (Remote Desktop) on Oracle Linux 8.5
How to install Xrdp Server (Remote Desktop) on Oracle Linux 8.5
Oct 17, 2022
How to install and update OpenSSL on Debian 11.3
How to install and update OpenSSL on Debian 11.3
Oct 21, 2022
How to install qBittorrent on Debian 9.0
How to install qBittorrent on Debian 9.0
Sep 8, 2017
How to Install FileZilla in Debian
How to Install FileZilla in Debian
Nov 29, 2016
How to install Nmap on Debian 9.0
How to install Nmap on Debian 9.0
Sep 9, 2017
How to Install Laravel in Debian
How to Install Laravel in Debian
Dec 7, 2016

Related Forums in How To Install PostgreSQL on Debian 11.3

Related Forums in How To Install PostgreSQL on Debian 11.3

PostgreSQL
stalin class=
How to uninstall postgresql from ubuntu
Nov 2, 2017
MariaDB
ryan class=
E: Unable to locate package mariadb-server
Sep 18, 2017
PostgreSQL
tommyhilten class=
Phpmyadmin : Login disallowed for security reasons in postgresql
Nov 3, 2017
Linux
AadrikaAnshu class=
How to add timestamps to history On Any Linux Machine
Jun 18, 2019
vim
jacob class=
Change true vi-compatible editor from Debian Vim-compatible
Nov 8, 2021
CentOS
jayce class=
Psql : could not connect to server: No such file or directory Is the server running locally and accepting connections on Unix domain socket "/var/run/postgresql/.s.PGSQL.45432"?
May 30, 2019
Ubuntu
Robattalion class=
Ubuntu 20.04 Installation Stuck
Sep 19, 2020
PostgreSQL
michael class=
Postgres password authentication fails
Nov 3, 2021

Related News in How To Install PostgreSQL on Debian 11.3

Related News in How To Install PostgreSQL on Debian 11.3

Debian IceDove kicks the bucket after Thunderbird revisits Debian Repositories
Debian IceDove kicks the bucket after Thunderbird revisits Debian Repositories
Feb 28, 2017
Mass update of Jessie - A better alternative to new version?
Mass update of Jessie - A better alternative to new version?
May 8, 2017
Amazon Web Services offers Aurora Cloud DB accordant with PostgreSQL
Amazon Web Services offers Aurora Cloud DB accordant with PostgreSQL
Oct 27, 2017
Debian 9.2 ‘Stretch’ OS is here, download distro now
Debian 9.2 ‘Stretch’ OS is here, download distro now
Oct 9, 2017
Back To Top!
Rank
User
Points

Top Contributers

userNamenaveelansari
135850

Top Contributers

userNameayanbhatti
92510

Top Contributers

userNamehamzaahmed
32150

Top Contributers

1
userNamelinuxhelp
31040

Top Contributers

userNamemuhammadali
24500
Can you help Luk Van De Looverbosch ?
How to create a root ?

Hello,
How to create root@linuxhelp in Linux Mint 20.1 64-bit ?
Thanks in advance for your reply.
Best regards.

Networking
  • Routing
  • trunk
  • Netmask
  • Packet Capture
  • domain
  • HTTP Proxy
Server Setup
  • NFS
  • KVM
  • Memory
  • Sendmail
  • WebDAV
  • LXC
Shell Commands
  • Cloud commander
  • Command line archive tools
  • last command
  • Shell
  • terminal
  • Throttle
Desktop Application
  • Linux app
  • Pithos
  • Retrospect
  • Scribe
  • TortoiseHg
  • 4Images
Monitoring Tool
  • Monit
  • Apache Server Monitoring
  • EtherApe 
  • Arpwatch Tool
  • Auditd
  • Barman
Web Application
  • Nutch
  • Amazon VPC
  • FarmWarDeployer
  • Rukovoditel
  • Mirror site
  • Chef
Contact Us | Terms of Use| Privacy Policy| Disclaimer
© 2025 LinuxHelp.com All rights reserved. Linux™ is the registered trademark of Linus Torvalds. This site is not affiliated with linus torvalds in any way.