Welcome to our guide on How To install PostgreSQL 16 on Rocky Linux 9. Relational database management system (RDBMS) PostgreSQL places a strong emphasis on flexibility and SQL conformance. PostgreSQL supports both SQL relational querying and JSON non-relational querying.
Table of Contents
Features of PostgreSQL 16
These awesome features are available in PostgreSQL 16;
- During replication, data can be filtered according to origin.
- Allow the analyze/vacuum command to specify a buffer consumption cap.
- A list of approved authentication procedures can now be specified using the new libpq connection option require_auth.
- During vacuum, allow freezing at page level.
- The support for text collations, which establish rules for sorting text, has been enhanced.
- Subscriptions can be made by non-superusers.
- The pre-defined collations Unicode and ucs_basic now have support.
- The effectiveness of relation extension has improved.
- Delegation of Kerberos credentials is now supported.
Install PostgreSQL 16 on Rocky Linux 9
To install PostgreSQL 16 on Rocky Linux 9, follow the procedure below;
Update Rocky Linux 9 System
It’s advisable to update any Linux distro before begining any installation. Run the following command to update Rocky Linux 9;
sudo dnf update
Reboot the system after the update;
sudo reboot now
Configure RPM repository on Rocky Linix 9
To set up an RPM repository, enter the following command;
sudo dnf install https://download.postgresql.org/pub/repos/yum/reporpms/EL-9-x86_64/pgdg-redhat-repo-latest.noarch.rpm -y
Output;
Last metadata expiration check: 0:15:56 ago on Tue 18 Apr 2023 02:13:10 PM CEST. Dependencies resolved. Nothing to do. Complete! [root@localhost ~]# sudo dnf install https://download.postgresql.org/pub/repos/yum/reporpms/EL-9-x86_64/pgdg-redhat-repo-latest.noarch.rpm -y Last metadata expiration check: 0:05:40 ago on Tue 18 Apr 2023 02:29:28 PM CEST. pgdg-redhat-repo-latest.noarch.rpm 71 kB/s | 11 kB 00:00 Dependencies resolved. ===================================================================================================== Package Architecture Version Repository Size ===================================================================================================== Installing: pgdg-redhat-repo noarch 42.0-35PGDG @commandline 11 k Transaction Summary ===================================================================================================== Install 1 Package Total size: 11 k Installed size: 15 k Downloading Packages: Running transaction check Transaction check succeeded. Running transaction test Transaction test succeeded. Running transaction Preparing : 1/1 Installing : pgdg-redhat-repo-42.0-35PGDG.noarch 1/1 Verifying : pgdg-redhat-repo-42.0-35PGDG.noarch 1/1 Installed: pgdg-redhat-repo-42.0-35PGDG.noarch Complete!
Disable the built-in PostgreSQL module on Rocky Linux 9
Turn off the integrated PostgreSQL module to proceed the installation;
sudo dnf -qy module disable postgresql
Install PostgreSQL 16 on Rocky Linux 9
Execute the following command to install PostgreSQL 16 on Rocky Linux 9;
sudo dnf install postgresql16-server
Output;
Dependencies resolved. ============================================================================================================================================================================================================ Package Architecture Version Repository Size ============================================================================================================================================================================================================ Installing: postgresql16-server x86_64 16.0-1PGDG.rhel9 pgdg16 6.7 M Installing dependencies: lz4 x86_64 1.9.3-5.el9 baseos 58 k postgresql16 x86_64 16.0-1PGDG.rhel9 pgdg16 1.7 M postgresql16-libs x86_64 16.0-1PGDG.rhel9 pgdg16 329 k Transaction Summary ============================================================================================================================================================================================================ Install 4 Packages Total download size: 8.8 M Installed size: 39 M Is this ok [y/N]: y
Confirm PostgreSQL installed version Rocky Linux 9;
psql --version
psql (PostgreSQL) 16.0
Initialize PostgreSQL 16 on Rocky Linux 9
After successful installation of PostgreSQL 16, run the following command to initilize it;
sudo /usr/pgsql-16/bin/postgresql-16-setup initdb
Initializing database ... OK
Start and Enable PostgreSQL 16 on Rocky Linux 9
Execute the command below to start and enable PostgreSQL 16 database on boot;
sudo systemctl start postgresql-16
sudo systemctl enable postgresql-16
Check the status of PostgreSQL 16;
systemctl status postgresql-16
Output;
● postgresql-16.service - PostgreSQL 16 database server Loaded: loaded (/usr/lib/systemd/system/postgresql-16.service; enabled; vendor preset: disabled) Active: active (running) since Tue 2023-04-18 14:44:31 CEST; 1min 31s ago Docs: https://www.postgresql.org/docs/16/static/ Main PID: 90677 (postgres) Tasks: 7 (limit: 23440) Memory: 19.5M CPU: 90ms CGroup: /system.slice/postgresql-16.service ├─90677 /usr/pgsql-16/bin/postgres -D /var/lib/pgsql/16/data/ ├─90678 "postgres: logger " ├─90679 "postgres: checkpointer " ├─90680 "postgres: background writer " ├─90682 "postgres: walwriter " ├─90683 "postgres: autovacuum launcher " └─90684 "postgres: logical replication launcher " Apr 18 14:44:31 localhost.localdomain systemd[1]: Starting PostgreSQL 16 database server... Apr 18 14:44:31 localhost.localdomain postgres[90677]: 2023-04-18 14:44:31.547 CEST [90677] LOG: redirecting log output to logging collector process Apr 18 14:44:31 localhost.localdomain postgres[90677]: 2023-04-18 14:44:31.547 CEST [90677] HINT: Future log output will appear in directory "log". Apr 18 14:44:31 localhost.localdomain systemd[1]: Started PostgreSQL 16 database server.
Connect and Secure PostgreSQL 16 on Rocky Linux 9
Use the PostgreSQL CLI to manage databases;
sudo -Hiu postgres psql
Output;
psql (16.0)
Type "help" for help.
postgres=#
Set PostgreSQL Strong Password;
postgres=# psql -c "ALTER USER postgres with password 'Str0ngPassw0rd'"
Create PostgreSQL 16 User and Database
Run the following command to create a user with password on PostgreSQL 16;
postgres=# CREATE USER itnixpro WITH PASSWORD 'YourStrongPassword';
CREATE ROLE
After creating the user, execute the following command to create the database;
postgres=# CREATE DATABASE nixdb OWNER itnixpro;
CREATE DATABASE
List databases on your PostgreSQL 16;
\l
Output;
List of databases Name | Owner | Encoding | Locale Provider | Collate | Ctype | ICU Locale | ICU Rules | Access privileges -----------+----------+----------+-----------------+-------------+-------------+------------+-----------+----------------------- nixdb | itnixpro | UTF8 | libc | en_US.UTF-8 | en_US.UTF-8 | | | postgres | postgres | UTF8 | libc | en_US.UTF-8 | en_US.UTF-8 | | | template0 | postgres | UTF8 | libc | en_US.UTF-8 | en_US.UTF-8 | | | =c/postgres + | | | | | | | | postgres=CTc/postgres template1 | postgres | UTF8 | libc | en_US.UTF-8 | en_US.UTF-8 | | | =c/postgres + | | | | | | | | postgres=CTc/postgres (4 rows)
Exit PostgreSQL 16 database as shown below;
\q
Or type “exit” to exit.
The End!
Congratulations! This completes our tutorial on installing PostgreSQL 16 on Rocky Linux 9. This guide is meant to be helpful. Keep checking our platform for more interesting guides.
More Guides to Check
How To Install PostgreSQL 16 on Debian 12
Install Brave Browser on Debian 12
Essential Tips to Consider Before You Choose a Skin Trading Platform