{"id":10179,"date":"2021-08-30T21:53:13","date_gmt":"2021-08-30T18:53:13","guid":{"rendered":"https:\/\/kifarunix.com\/?p=10179"},"modified":"2024-03-18T18:33:37","modified_gmt":"2024-03-18T15:33:37","slug":"install-postgresql-13-on-debian-11","status":"publish","type":"post","link":"https:\/\/kifarunix.com\/install-postgresql-13-on-debian-11\/","title":{"rendered":"Install PostgreSQL 13 on Debian 11"},"content":{"rendered":"\n<p>Follow through this guide to learn how to install PostgreSQL 13 on Debian 11. <a href=\"https:\/\/www.postgresql.org\/about\/\" target=\"_blank\" rel=\"noreferrer noopener\">PostgreSQL<\/a> 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.<\/p>\n\n\n\n<p>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.<\/p>\n\n\n\n<p>PostgreSQL is a powerful, open source object-relational database system that uses and extends the SQL language combined with many features that safely store and scale the most complicated data workloads.<\/p>\n\n\n\n<div class=\"wp-block-rank-math-toc-block\" id=\"rank-math-toc\"><h2>Table of Contents<\/h2><nav><ul><li><a href=\"#installing-postgre-sql-13-on-debian-11\">Installing PostgreSQL 13 on Debian 11<\/a><ul><li><a href=\"#install-postgre-sql-13\">Install PostgreSQL 13<\/a><\/li><li><a href=\"#running-postgre-sql\">Running PostgreSQL<\/a><\/li><li><a href=\"#installing-other-versions-of-postgre-sql-on-debian-11\">Installing Other Versions of PostgreSQL on Debian 11<\/a><\/li><li><a href=\"#install-postgre-sql-12-on-debian-11\">Install PostgreSQL 12 on Debian 11<\/a><\/li><li><a href=\"#install-postgre-sql-11-on-debian-11\">Install PostgreSQL 11 on Debian 11<\/a><\/li><li><a href=\"#verifying-version-of-installed-postgre-sql-on-command-line\">Verifying Version of Installed PostgreSQL on command line<\/a><\/li><li><a href=\"#logging-into-postgre-sql\">Logging into PostgreSQL<\/a><\/li><li><a href=\"#getting-started-with-postgre-sql\">Getting Started with PostgreSQL<\/a><\/li><li><a href=\"#other-tutorials\">Other Tutorials<\/a><\/li><\/ul><\/li><\/ul><\/nav><\/div>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"installing-postgre-sql-13-on-debian-11\">Installing PostgreSQL 13 on Debian 11<\/h2>\n\n\n\n<p>As of this writing, PostgreSQL 13 is the current major PostgreSQL release.<\/p>\n\n\n\n<p>Fortunately, the default Debian 11 main repositories provides PostgreSQL packages.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>apt-cache policy postgresql<\/code><\/pre>\n\n\n\n<pre class=\"wp-block-code\"><code>postgresql:\n  Installed: (none)\n  Candidate: 13+225\n  Version table:\n     13+225 500\n        500 http:\/\/deb.debian.org\/debian bullseye\/main amd64 Packages<\/code><\/pre>\n\n\n\n<p>This makes it easy to install PostgreSQL 13.x on Debian 11.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"install-postgre-sql-13\">Install PostgreSQL 13<\/h3>\n\n\n\n<p>To install PostgreSQL 13, run the command below;<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>apt install postgresql postgresql-contrib<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"running-postgre-sql\">Running PostgreSQL<\/h3>\n\n\n\n<p>When installation is done, PostgreSQL is set to run and start on system boot. Confirm by checking the service.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>systemctl status postgresql@13-main.service<\/code><\/pre>\n\n\n\n<pre class=\"scroll-box\"><code>\n\u25cf postgresql@13-main.service - PostgreSQL Cluster 13-main\n     Loaded: loaded (\/lib\/systemd\/system\/postgresql@.service; enabled-runtime; vendor preset: enabled)\n     Active: active (running) since Mon 2021-08-30 20:17:45 EAT; 1min 25s ago\n   Main PID: 3588 (postgres)\n      Tasks: 7 (limit: 1133)\n     Memory: 17.4M\n        CPU: 199ms\n     CGroup: \/system.slice\/system-postgresql.slice\/postgresql@13-main.service\n             \u251c\u25003588 \/usr\/lib\/postgresql\/13\/bin\/postgres -D \/var\/lib\/postgresql\/13\/main -c config_file=\/etc\/postgresql\/13\/main\/postgresql.conf\n             \u251c\u25003590 postgres: 13\/main: checkpointer\n             \u251c\u25003591 postgres: 13\/main: background writer\n             \u251c\u25003592 postgres: 13\/main: walwriter\n             \u251c\u25003593 postgres: 13\/main: autovacuum launcher\n             \u251c\u25003594 postgres: 13\/main: stats collector\n             \u2514\u25003595 postgres: 13\/main: logical replication launcher\n\nAug 30 20:17:42 debian11 systemd[1]: Starting PostgreSQL Cluster 13-main...\nAug 30 20:17:45 debian11 systemd[1]: Started PostgreSQL Cluster 13-main.\n<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"installing-other-versions-of-postgre-sql-on-debian-11\">Installing Other Versions of PostgreSQL on Debian 11<\/h3>\n\n\n\n<p>If you want to install other versions of PostgreSQL on Debian 11, you need to add the PostgreSQL apt repository;<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>echo \"deb http:\/\/apt.postgresql.org\/pub\/repos\/apt $(lsb_release -cs)-pgdg main\" &gt; \/etc\/apt\/sources.list.d\/pgdg.list<\/code><\/pre>\n\n\n\n<pre class=\"wp-block-code\"><code>curl -sL https:\/\/www.postgresql.org\/media\/keys\/ACCC4CF8.asc | sudo tee \/etc\/apt\/trusted.gpg.d\/pgdg.asc &gt;\/dev\/null <\/code><\/pre>\n\n\n\n<pre class=\"wp-block-code\"><code>apt update<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"install-postgre-sql-12-on-debian-11\">Install PostgreSQL 12 on Debian 11<\/h3>\n\n\n\n<pre class=\"wp-block-code\"><code>apt install postgresql-12 postgresql-contrib-12<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"install-postgre-sql-11-on-debian-11\">Install PostgreSQL 11 on Debian 11<\/h3>\n\n\n\n<pre class=\"wp-block-code\"><code>apt install postgresql-11 postgresql-contrib-11<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"verifying-version-of-installed-postgre-sql-on-command-line\">Verifying Version of Installed PostgreSQL on command line<\/h3>\n\n\n\n<p>You can find the version of install PostgreSQL on command line using the command below;<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>\/usr\/lib\/postgresql\/13\/bin\/postgres -V<\/code><\/pre>\n\n\n\n<p>Sample command output;<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>postgres (PostgreSQL) 13.3 (Debian 13.3-1)<\/code><\/pre>\n\n\n\n<p>Similarly, you can use the command;<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>sudo -Hiu postgres psql -c \"SELECT version();\"<\/code><\/pre>\n\n\n\n<p>Sample output;<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>                                                      version                                                      \n-------------------------------------------------------------------------------------------------------------------\n PostgreSQL 13.3 (Debian 13.3-1) on x86_64-pc-linux-gnu, compiled by gcc (Debian 10.2.1-6) 10.2.1 20210110, 64-bit\n(1 row)<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"logging-into-postgre-sql\">Logging into PostgreSQL<\/h3>\n\n\n\n<p>By default, <code>postgres<\/code> user is created upon the installation of PostgreSQL.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>id postgres<\/code><\/pre>\n\n\n\n<pre class=\"wp-block-code\"><code>uid=107(postgres) gid=115(postgres) groups=115(postgres),114(ssl-cert)<\/code><\/pre>\n\n\n\n<p>The home directory for the user is set to <code>\/var\/lib\/postgresql<\/code>.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>getent passwd postgres<\/code><\/pre>\n\n\n\n<pre class=\"wp-block-code\"><code>postgres:x:107:115:PostgreSQL administrator,,,:\/var\/lib\/postgresql:\/bin\/bash<\/code><\/pre>\n\n\n\n<p>Hence, to login to PostgreSQL, first switch to <code>postgres<\/code> user using the command;<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>sudo -Hiu postgres<\/code><\/pre>\n\n\n\n<p>Once you are logged in, you can then run the <code><strong>psql<\/strong><\/code> command to get to PostgreSQL shell. <strong><code>psql<\/code><\/strong> is a PostgreSQL interactive terminal command that enables you to type in queries interactively, issue them to PostgreSQL, and see the query results.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>psql<\/code><\/pre>\n\n\n\n<p>This changes the prompt as;<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>psql (13.3 (Debian 13.3-1))\nType \"help\" for help.\n\npostgres=#<\/code><\/pre>\n\n\n\n<p>Type <strong><code>help<\/code><\/strong> to see various command usage.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>help<\/code><\/pre>\n\n\n\n<pre class=\"wp-block-code\"><code>You are using psql, the command-line interface to PostgreSQL.\nType:  \\copyright for distribution terms\n       \\h for help with SQL commands\n       \\? for help with psql commands\n       \\g or terminate with semicolon to execute query\n       \\q to quit\npostgres=#<\/code><\/pre>\n\n\n\n<pre class=\"wp-block-code\"><code>\\h<\/code><\/pre>\n\n\n\n<pre class=\"scroll-box\"><code>\nAvailable help:\n  ABORT                            ALTER TEXT SEARCH TEMPLATE       CREATE PUBLICATION               DROP FUNCTION                    IMPORT FOREIGN SCHEMA\n  ALTER AGGREGATE                  ALTER TRIGGER                    CREATE ROLE                      DROP GROUP                       INSERT\n  ALTER COLLATION                  ALTER TYPE                       CREATE RULE                      DROP INDEX                       LISTEN\n  ALTER CONVERSION                 ALTER USER                       CREATE SCHEMA                    DROP LANGUAGE                    LOAD\n  ALTER DATABASE                   ALTER USER MAPPING               CREATE SEQUENCE                  DROP MATERIALIZED VIEW           LOCK\n  ALTER DEFAULT PRIVILEGES         ALTER VIEW                       CREATE SERVER                    DROP OPERATOR                    MOVE\n  ALTER DOMAIN                     ANALYZE                          CREATE STATISTICS                DROP OPERATOR CLASS              NOTIFY\n  ALTER EVENT TRIGGER              BEGIN                            CREATE SUBSCRIPTION              DROP OPERATOR FAMILY             PREPARE\n  ALTER EXTENSION                  CALL                             CREATE TABLE                     DROP OWNED                       PREPARE TRANSACTION\n  ALTER FOREIGN DATA WRAPPER       CHECKPOINT                       CREATE TABLE AS                  DROP POLICY                      REASSIGN OWNED\n  ALTER FOREIGN TABLE              CLOSE                            CREATE TABLESPACE                DROP PROCEDURE                   REFRESH MATERIALIZED VIEW\n  ALTER FUNCTION                   CLUSTER                          CREATE TEXT SEARCH CONFIGURATION DROP PUBLICATION                 REINDEX\n  ALTER GROUP                      COMMENT                          CREATE TEXT SEARCH DICTIONARY    DROP ROLE                        RELEASE SAVEPOINT\n  ALTER INDEX                      COMMIT                           CREATE TEXT SEARCH PARSER        DROP ROUTINE                     RESET\n  ALTER LANGUAGE                   COMMIT PREPARED                  CREATE TEXT SEARCH TEMPLATE      DROP RULE                        REVOKE\n  ALTER LARGE OBJECT               COPY                             CREATE TRANSFORM                 DROP SCHEMA                      ROLLBACK\n  ALTER MATERIALIZED VIEW          CREATE ACCESS METHOD             CREATE TRIGGER                   DROP SEQUENCE                    ROLLBACK PREPARED\n  ALTER OPERATOR                   CREATE AGGREGATE                 CREATE TYPE                      DROP SERVER                      ROLLBACK TO SAVEPOINT\n  ALTER OPERATOR CLASS             CREATE CAST                      CREATE USER                      DROP STATISTICS                  SAVEPOINT\n  ALTER OPERATOR FAMILY            CREATE COLLATION                 CREATE USER MAPPING              DROP SUBSCRIPTION                SECURITY LABEL\n  ALTER POLICY                     CREATE CONVERSION                CREATE VIEW                      DROP TABLE                       SELECT\n  ALTER PROCEDURE                  CREATE DATABASE                  DEALLOCATE                       DROP TABLESPACE                  SELECT INTO\n  ALTER PUBLICATION                CREATE DOMAIN                    DECLARE                          DROP TEXT SEARCH CONFIGURATION   SET\n  ALTER ROLE                       CREATE EVENT TRIGGER             DELETE                           DROP TEXT SEARCH DICTIONARY      SET CONSTRAINTS\n  ALTER ROUTINE                    CREATE EXTENSION                 DISCARD                          DROP TEXT SEARCH PARSER          SET ROLE\n  ALTER RULE                       CREATE FOREIGN DATA WRAPPER      DO                               DROP TEXT SEARCH TEMPLATE        SET SESSION AUTHORIZATION\n  ALTER SCHEMA                     CREATE FOREIGN TABLE             DROP ACCESS METHOD               DROP TRANSFORM                   SET TRANSACTION\n  ALTER SEQUENCE                   CREATE FUNCTION                  DROP AGGREGATE                   DROP TRIGGER                     SHOW\n  ALTER SERVER                     CREATE GROUP                     DROP CAST                        DROP TYPE                        START TRANSACTION\n  ALTER STATISTICS                 CREATE INDEX                     DROP COLLATION                   DROP USER                        TABLE\n  ALTER SUBSCRIPTION               CREATE LANGUAGE                  DROP CONVERSION                  DROP USER MAPPING                TRUNCATE\n  ALTER SYSTEM                     CREATE MATERIALIZED VIEW         DROP DATABASE                    DROP VIEW                        UNLISTEN\n  ALTER TABLE                      CREATE OPERATOR                  DROP DOMAIN                      END                              UPDATE\n  ALTER TABLESPACE                 CREATE OPERATOR CLASS            DROP EVENT TRIGGER               EXECUTE                          VACUUM\n  ALTER TEXT SEARCH CONFIGURATION  CREATE OPERATOR FAMILY           DROP EXTENSION                   EXPLAIN                          VALUES\n  ALTER TEXT SEARCH DICTIONARY     CREATE POLICY                    DROP FOREIGN DATA WRAPPER        FETCH                            WITH\n  ALTER TEXT SEARCH PARSER         CREATE PROCEDURE                 DROP FOREIGN TABLE               GRANT                            \npostgres=#\n<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"getting-started-with-postgre-sql\">Getting Started with PostgreSQL<\/h3>\n\n\n\n<p>You can now get started with PostgreSQL.<\/p>\n\n\n\n<p>Check <a href=\"https:\/\/www.postgresql.org\/docs\/13\/tutorial.html\" target=\"_blank\" rel=\"noreferrer noopener\">Getting Started with<\/a> PostgreSQL on the documentation page to learn more about PostgreSQL.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"other-tutorials\">Other Tutorials<\/h3>\n\n\n\n<p><a href=\"https:\/\/kifarunix.com\/install-nodejs-debian-11\/\" target=\"_blank\" rel=\"noreferrer noopener\">Install Nodejs Debian 11<\/a><\/p>\n\n\n\n<p><a href=\"https:\/\/kifarunix.com\/install-yarn-on-debian-11\/\" target=\"_blank\" rel=\"noreferrer noopener\">Install Yarn on Debian 11<\/a><\/p>\n\n\n\n<p><a href=\"https:\/\/kifarunix.com\/install-yarn-on-rocky-linux-8\/\" target=\"_blank\" rel=\"noreferrer noopener\">Install Yarn on Rocky Linux 8<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Follow through this guide to learn how to install PostgreSQL 13 on Debian 11. PostgreSQL is a fully featured object-relational database management system. It supports<\/p>\n","protected":false},"author":3,"featured_media":10267,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"rank_math_lock_modified_date":false,"footnotes":""},"categories":[121],"tags":[3958,4041,4039,4038,4037,4036,990,4042,4040],"class_list":["post-10179","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-howtos","tag-debian-11","tag-debian-11-postgresql-install","tag-install-postgresql-11-on-debian-11","tag-install-postgresql-12-on-debian-11","tag-install-postgresql-13-on-debian-11","tag-install-postgresql-on-debian-11","tag-postgresql","tag-postgresql-13","tag-postgresql-debain-11","generate-columns","tablet-grid-50","mobile-grid-100","grid-parent","grid-50","resize-featured-image"],"_links":{"self":[{"href":"https:\/\/kifarunix.com\/wp-json\/wp\/v2\/posts\/10179"}],"collection":[{"href":"https:\/\/kifarunix.com\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/kifarunix.com\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/kifarunix.com\/wp-json\/wp\/v2\/users\/3"}],"replies":[{"embeddable":true,"href":"https:\/\/kifarunix.com\/wp-json\/wp\/v2\/comments?post=10179"}],"version-history":[{"count":6,"href":"https:\/\/kifarunix.com\/wp-json\/wp\/v2\/posts\/10179\/revisions"}],"predecessor-version":[{"id":21669,"href":"https:\/\/kifarunix.com\/wp-json\/wp\/v2\/posts\/10179\/revisions\/21669"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/kifarunix.com\/wp-json\/wp\/v2\/media\/10267"}],"wp:attachment":[{"href":"https:\/\/kifarunix.com\/wp-json\/wp\/v2\/media?parent=10179"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/kifarunix.com\/wp-json\/wp\/v2\/categories?post=10179"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/kifarunix.com\/wp-json\/wp\/v2\/tags?post=10179"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}