{"id":10044,"date":"2021-09-20T13:09:48","date_gmt":"2021-09-20T13:09:48","guid":{"rendered":"https:\/\/linuxways.net\/?p=10044"},"modified":"2021-09-20T13:09:48","modified_gmt":"2021-09-20T13:09:48","slug":"install-postgresql-13-on-debian-11","status":"publish","type":"post","link":"https:\/\/linuxways.net\/de\/debian\/install-postgresql-13-on-debian-11\/","title":{"rendered":"Install PostgreSQL 13 on Debian 11"},"content":{"rendered":"<p><a href=\"https:\/\/www.postgresql.org\/\">PostgreSQL<\/a> is a popular household name amongst database administrators and developers. It is a powerful and opensource Relational Database Management System ( RDBMS ) that leverages the SQL query language to create and manipulate databases. With over 30 years of active development, PostgreSQL is widely used as a database for numerous mobile and web applications. Some of the notable Tech giants that use PostgreSQL include Instagram, Uber, spotify, and Reddit.<\/p>\n<p>PostgreSQL 13 is the current stable version of PostgreSQL. It ships with new features including incremental sorting, parallel vacuuming and optimizations such as better data management for big or small workloads and security enhancements.<\/p>\n<p>In this walkthrough, we explore the installation of PostgreSQL 13 on Debian 11 . You might also consider checking out this guide on how to <a href=\"https:\/\/linuxways.net\/de\/red-hat\/how-to-install-postgresql-13-on-rocky-linux\/\">install PostgreSQL 13 on Rocky Linux 8<\/a>.<\/p>\n<h2><strong>Prerequisites<\/strong><\/h2>\n<p>To get started, ensure you have an Debian 11 server instance with SSH access and a sudo user already configured for executing privileged tasks.<\/p>\n<h2><strong>Step 1: Install PostgreSQL 13<\/strong><\/h2>\n<p>Thankfully, the latest version of PostgreSQL &#8211; PostgreSQL 13 &#8211; is hosted on Debian repository. You can confirm this as shown in the command below.<\/p>\n<pre><strong>$ apt-cache postgresql<\/strong><\/pre>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"713\" height=\"136\" class=\"wp-image-10045\" src=\"http:\/\/linuxways.net\/wp-content\/uploads\/2021\/09\/word-image-239.png\" srcset=\"https:\/\/linuxways.net\/wp-content\/uploads\/2021\/09\/word-image-239.png 713w, https:\/\/linuxways.net\/wp-content\/uploads\/2021\/09\/word-image-239-300x57.png 300w\" sizes=\"auto, (max-width: 713px) 100vw, 713px\" \/><\/p>\n<p>Therefore, to install PostgreSQL 13, first update Debian 11 package index.<\/p>\n<pre><strong>$ sudo apt update<\/strong><\/pre>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"896\" height=\"167\" class=\"wp-image-10046\" src=\"http:\/\/linuxways.net\/wp-content\/uploads\/2021\/09\/word-image-240.png\" srcset=\"https:\/\/linuxways.net\/wp-content\/uploads\/2021\/09\/word-image-240.png 896w, https:\/\/linuxways.net\/wp-content\/uploads\/2021\/09\/word-image-240-300x56.png 300w, https:\/\/linuxways.net\/wp-content\/uploads\/2021\/09\/word-image-240-768x143.png 768w\" sizes=\"auto, (max-width: 896px) 100vw, 896px\" \/><\/p>\n<p>Thereafter, use the APT package manager to install PostgreSQL 13 alongside other additional packages and dependencies:<\/p>\n<pre><strong>$ sudo apt install postgresql postgresql-contrib<\/strong><\/pre>\n<p>This installs PostgreSQL, and additional software packages and their dependencies.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"865\" height=\"261\" class=\"wp-image-10047\" src=\"http:\/\/linuxways.net\/wp-content\/uploads\/2021\/09\/word-image-241.png\" srcset=\"https:\/\/linuxways.net\/wp-content\/uploads\/2021\/09\/word-image-241.png 865w, https:\/\/linuxways.net\/wp-content\/uploads\/2021\/09\/word-image-241-300x91.png 300w, https:\/\/linuxways.net\/wp-content\/uploads\/2021\/09\/word-image-241-768x232.png 768w\" sizes=\"auto, (max-width: 865px) 100vw, 865px\" \/><\/p>\n<p>Once done, head over to the next step.<\/p>\n<h2><strong>Step 2: Confirm the status of PostgreSQL 13<\/strong><\/h2>\n<p>The PostgreSQL database service should start automatically without intervention. Verify this with the command:<\/p>\n<pre><strong>$ sudo systemctl status postgresql@13-main.service<\/strong><\/pre>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"903\" height=\"202\" class=\"wp-image-10048\" src=\"http:\/\/linuxways.net\/wp-content\/uploads\/2021\/09\/word-image-242.png\" srcset=\"https:\/\/linuxways.net\/wp-content\/uploads\/2021\/09\/word-image-242.png 903w, https:\/\/linuxways.net\/wp-content\/uploads\/2021\/09\/word-image-242-300x67.png 300w, https:\/\/linuxways.net\/wp-content\/uploads\/2021\/09\/word-image-242-768x172.png 768w\" sizes=\"auto, (max-width: 903px) 100vw, 903px\" \/><\/p>\n<p>Alternatively, you can run the following command to confirm its status. The output will provide the status of the server including the PID ( Process ID ).<\/p>\n<pre><strong>$ sudo pg_ctlcluster 13 main status<\/strong><\/pre>\n<p>pg_ctlcluster 13<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"903\" height=\"105\" class=\"wp-image-10049\" src=\"http:\/\/linuxways.net\/wp-content\/uploads\/2021\/09\/word-image-243.png\" srcset=\"https:\/\/linuxways.net\/wp-content\/uploads\/2021\/09\/word-image-243.png 903w, https:\/\/linuxways.net\/wp-content\/uploads\/2021\/09\/word-image-243-300x35.png 300w, https:\/\/linuxways.net\/wp-content\/uploads\/2021\/09\/word-image-243-768x89.png 768w\" sizes=\"auto, (max-width: 903px) 100vw, 903px\" \/> main status<\/p>\n<p>If you are curious enough, you can check the version installed as follows:<\/p>\n<pre><strong>$ \/usr\/lib\/postgresql\/bin\/postgres -V<\/strong><\/pre>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"607\" height=\"100\" class=\"wp-image-10050\" src=\"http:\/\/linuxways.net\/wp-content\/uploads\/2021\/09\/word-image-244.png\" srcset=\"https:\/\/linuxways.net\/wp-content\/uploads\/2021\/09\/word-image-244.png 607w, https:\/\/linuxways.net\/wp-content\/uploads\/2021\/09\/word-image-244-300x49.png 300w\" sizes=\"auto, (max-width: 607px) 100vw, 607px\" \/><\/p>\n<h2><strong>Step 3: Starting and enabling PostgreSQL 13<\/strong><\/h2>\n<p>If by any chance PostgreSQL is not running or is inactive, you can start it using the command:<\/p>\n<pre><strong>$ sudo systemctl start postgresql@13-main.service<\/strong><\/pre>\n<p>To make PostgreSQL automatically start every time the system is powered on or rebooted, enable it as follows.<\/p>\n<pre><strong>$ sudo systemctl enable postgresql@13-main.service<\/strong><\/pre>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"903\" height=\"142\" class=\"wp-image-10051\" src=\"http:\/\/linuxways.net\/wp-content\/uploads\/2021\/09\/word-image-245.png\" srcset=\"https:\/\/linuxways.net\/wp-content\/uploads\/2021\/09\/word-image-245.png 903w, https:\/\/linuxways.net\/wp-content\/uploads\/2021\/09\/word-image-245-300x47.png 300w, https:\/\/linuxways.net\/wp-content\/uploads\/2021\/09\/word-image-245-768x121.png 768w\" sizes=\"auto, (max-width: 903px) 100vw, 903px\" \/><\/p>\n<h2><strong>Step 4: Accessing PostgreSQL 13 database server<\/strong><\/h2>\n<p>When PostgreSQL is installed, a new user called <strong>postgres <\/strong>is created by default. You can confirm this by having a peek at the <strong>\/etc\/passwd <\/strong>file which stores users\u2019 information such as UID and GID,<\/p>\n<pre><strong>$ cat \/etc\/passwd | grep -i postgres<\/strong><\/pre>\n<p>To make matters simpler, you can invoke the <strong>id <\/strong>command<\/p>\n<pre><strong>$ id postgres<\/strong><\/pre>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"751\" height=\"176\" class=\"wp-image-10052\" src=\"http:\/\/linuxways.net\/wp-content\/uploads\/2021\/09\/word-image-246.png\" srcset=\"https:\/\/linuxways.net\/wp-content\/uploads\/2021\/09\/word-image-246.png 751w, https:\/\/linuxways.net\/wp-content\/uploads\/2021\/09\/word-image-246-300x70.png 300w\" sizes=\"auto, (max-width: 751px) 100vw, 751px\" \/><\/p>\n<p>To connect to the database, switch to the <strong>postgres <\/strong>user as shown.<\/p>\n<pre><strong>$ sudo su - postgres<\/strong><\/pre>\n<p>Then access the PostgreSQL interactive shell as shown<\/p>\n<pre><strong>$ psql<\/strong><\/pre>\n<p><strong><img loading=\"lazy\" decoding=\"async\" width=\"552\" height=\"183\" class=\"wp-image-10053\" src=\"http:\/\/linuxways.net\/wp-content\/uploads\/2021\/09\/word-image-247.png\" srcset=\"https:\/\/linuxways.net\/wp-content\/uploads\/2021\/09\/word-image-247.png 552w, https:\/\/linuxways.net\/wp-content\/uploads\/2021\/09\/word-image-247-300x99.png 300w\" sizes=\"auto, (max-width: 552px) 100vw, 552px\" \/><\/strong><\/p>\n<p>The interactive shell allows you to run SQL queries and perform all matter of SQL queries. Run the <strong>help <\/strong>command to view some command usages<\/p>\n<pre><strong>postgres=# help<\/strong><\/pre>\n<p><strong><img loading=\"lazy\" decoding=\"async\" width=\"592\" height=\"269\" class=\"wp-image-10054\" src=\"http:\/\/linuxways.net\/wp-content\/uploads\/2021\/09\/word-image-248.png\" srcset=\"https:\/\/linuxways.net\/wp-content\/uploads\/2021\/09\/word-image-248.png 592w, https:\/\/linuxways.net\/wp-content\/uploads\/2021\/09\/word-image-248-300x136.png 300w\" sizes=\"auto, (max-width: 592px) 100vw, 592px\" \/><\/strong><\/p>\n<p>To exit the shell, simply run:<\/p>\n<pre><strong># \\q<\/strong><\/pre>\n<p>Then exit from the <strong>postgres<\/strong> user session.<\/p>\n<pre><strong>$ exit<\/strong><\/pre>\n<h2><strong>Conclusion<\/strong><\/h2>\n<p>This closes the curtain on this guide. We have walked you through a step-by-step procedure of installing PostgreSQL 13 on Debian 11 Bulls-Eye.<\/p>","protected":false},"excerpt":{"rendered":"<p>PostgreSQL is a popular household name amongst database administrators and developers. It is a powerful and opensource Relational Database Management System ( RDBMS ) that leverages the SQL&hellip;<\/p>","protected":false},"author":1,"featured_media":10300,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[4],"tags":[521,415],"class_list":["post-10044","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-debian","tag-debian-11","tag-postgresql-13"],"_links":{"self":[{"href":"https:\/\/linuxways.net\/de\/wp-json\/wp\/v2\/posts\/10044","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/linuxways.net\/de\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/linuxways.net\/de\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/linuxways.net\/de\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/linuxways.net\/de\/wp-json\/wp\/v2\/comments?post=10044"}],"version-history":[{"count":0,"href":"https:\/\/linuxways.net\/de\/wp-json\/wp\/v2\/posts\/10044\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/linuxways.net\/de\/wp-json\/wp\/v2\/media\/10300"}],"wp:attachment":[{"href":"https:\/\/linuxways.net\/de\/wp-json\/wp\/v2\/media?parent=10044"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/linuxways.net\/de\/wp-json\/wp\/v2\/categories?post=10044"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/linuxways.net\/de\/wp-json\/wp\/v2\/tags?post=10044"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}