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

How To Install and Create DB/User In PostgreSQL on Rocky Linux 8.6

  • 00:29 cat /etc/os-release
  • 00:46 yum model list | grep postgresql
  • 01:14 yum install @postgresql
  • 01:46 postgresql-setup --initdb
  • 02:06 passwd postgres
  • 02:25 systemctl status postgresql.service
  • 02:52 systemctl start postgresql.service
  • 02:56 systemctl enable postgresql.service
  • 03:24 sudo -i -u postgres
  • 03:37 psql
  • 03:47 create database Test_db;
  • 04:05 create user psql_user with encrypted password 'Linuxc#4';
  • 04:45 grant all privileges on database Test_db to psql_user;
  • 05:21 \l
  • 05:33 \q
7101

To Install & Create DB/User In PostgreSQL On Rocky Linux 8.6

Introduction:

PostgreSQL is a powerful, open source object-relational database system that has over 15 years of the active development phase and a proven architecture that has obtained a strong reputation for reliability, data integrity, and correctness.

Installation Procedure:

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

[root@linuxhelp ~]# cat /etc/os-release 
NAME="Rocky Linux"
VERSION="8.6 (Green Obsidian)"
ID="rocky"
ID_LIKE="rhel centos fedora"
VERSION_ID="8.6"
PLATFORM_ID="platform:el8"
PRETTY_NAME="Rocky Linux 8.6 (Green Obsidian)"

Step 2: List all available PostgreSQL by using the below command

[root@linuxhelp ~]# yum model list | grep postgresql
No such command: model. Please use /usr/bin/yum --help
It could be a YUM plugin command, try: "yum install 'dnf-command(model)'"

[root@linuxhelp ~]# yum module list | grep postgresql
postgresql           9.6             client, server [d]                       PostgreSQL server and client module                                                                                                                                                                                              
postgresql           10 [d]          client, server [d]                       PostgreSQL server and client module                                                                                                                                                                                              
postgresql           12              client, server [d]                       PostgreSQL server and client module                                                                                                                                                                                              
postgresql           13              client, server [d]                       PostgreSQL server and 

Step 3: Install PostgreSQL by default is PostgreSQL 10

[root@linuxhelp ~]# yum install @postgresql
Last metadata expiration check: 0:03:32 ago on Tue 05 Jul 2022 12:57:33 AM EDT.
Dependencies resolved.
====================================================================================================
 Package                Arch        Version                                    Repository      Size
====================================================================================================
Installing group/module packages:
 postgresql-server      x86_64      10.21-2.module+el8.6.0+977+ab6e685c        appstream      5.1 M
Installing module profiles:
 postgresql/server                                                                                 

Transaction Summary
====================================================================================================
Install  1 Package
Total download size: 5.1 M
Installed size: 20 M
Is this ok [y/N]: y
Downloading Packages:
postgresql-server-10.21-2.module+el8.6.0+977+ab6e685c.x86_64.rpm    3.4 MB/s | 5.1 MB     00:01    
---------------------------------------------------------------------------------------------------

Step 4: Initialize new PostgreSQL database cluster by using the below command

[root@linuxhelp ~]# postgresql-setup --initdb
 * Initializing database in '/var/lib/pgsql/data'
 * Initialized, logs are in /var/lib/pgsql/initdb_postgresql.log

Step 5: Setup a password for PostgreSQL account by using the below command

[root@linuxhelp ~]# passwd postgres
Changing password for user postgres.
New password: 
Retype new password: 
passwd: all authentication tokens updated successfully.

Step 6: Check the status of PostgreSQL by using the below command

[root@linuxhelp ~]# systemctl status postgresql.service 
● postgresql.service - PostgreSQL database server
   Loaded: loaded (/usr/lib/systemd/system/postgresql.service; disabled; vendor preset: disabled)
   Active: inactive (dead)

Step 7: Start the PostgreSQL by using the below command

[root@linuxhelp ~]# systemctl start postgresql.service

Step 8: Enable the PostgreSQL by using the below command

[root@linuxhelp ~]# systemctl enable postgresql.service 
Created symlink /etc/systemd/system/multi-user.target.wants/postgresql.service → /usr/lib/systemd/system/postgresql.service.

Step 9: Log as postgres user by using the below command

[root@linuxhelp ~]# sudo -i -u postgres
[postgres@linuxhelp ~]$ 

Step 10: Run PostgreSQL by using the below command

[postgres@linuxhelp ~]$ psql
psql (10.21)
Type "help" for help.

Step 11: Create a database by using the below command

postgres=# create database Test_db;
CREATE DATABASE

Step 12: Create a user by using the below command

postgres=# create user psql_user with encrypted password 'Linuxc#4';

Step 13: Grant all privileges for “psql_user” user to “Test_db” database by using the below command

postgres=# grant all privileges on database Test_db to psql_user;
GRANT

Step 14: List the PostgreSQL database by using the below command

postgres=# \l
                                  List of databases
   Name    |  Owner   | Encoding |   Collate   |    Ctype    |   Access privileges    
-----------+----------+----------+-------------+-------------+------------------------
 postgres  | postgres | UTF8     | en_US.UTF-8 | en_US.UTF-8 | 
 template0 | postgres | UTF8     | en_US.UTF-8 | en_US.UTF-8 | =c/postgres           +
           |          |          |             |             | postgres=CTc/postgres
 template1 | postgres | UTF8     | en_US.UTF-8 | en_US.UTF-8 | =c/postgres           +
           |          |          |             |             | postgres=CTc/postgres
 test_db   | postgres | UTF8     | en_US.UTF-8 | en_US.UTF-8 | =Tc/postgres          +
           |          |          |             |             | postgres=CTc/postgres +
           |          |          |             |             | psql_user=CTc/postgres
(4 rows)

Step 15: Exit the PostgresSQL by using the below command

postgres=# \q
[postgres@linuxhelp ~]$ 

Conclusion:

We have reached the end of this article. In this guide, we have walked you through the steps required to install & create DB/user in PostgreSQL on Rocky Linux 8.6. Your feedback is much welcome.

Tags:
gabriel
Author: 

Comments ( 0 )

No comments available

Add a comment

Frequently asked questions ( 5 )

Q

List some of the features of PostgreSQL?

A

Object-relational database,Supports major Operating systems,Support Extensibility for SQL and Complex SQL queries,Nested transactions,Multi-version concurrency control (MVCC) and Procedural languages.

Q

List different datatypes of PostgreSQL?

A

UUID,Numeric types,Boolean,Character types,Temporal types,Geometric primitives.

Q

What are some of the advantages of PostgreSQL?

A

Stable,Reliable,Extensible,Easy to learn,Open source,Designed for High Volume Environments,Cross Platform,Better Support,Flexible.

Q

What is the default version of PostgreSQL install

A

The default version for PostgreSQL 10

Q

What is the PostgreSQL initialization command?

A

postgresql-setup --initdb

Related Tutorials in How To Install and Create DB/User In PostgreSQL on Rocky Linux 8.6

Related Tutorials in How To Install and Create DB/User In PostgreSQL on Rocky Linux 8.6

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 and Configure Mega in Linux
How to Install and Configure Mega in Linux
Jul 19, 2016
How to use Aureport command on Linux
How to use Aureport command on Linux
Nov 28, 2017
How to install Development tools on Linux
How to install Development tools on Linux
Jun 12, 2018
How to Install mod_ssl and SSL certificate on Oracle Linux
How to Install mod_ssl and SSL certificate on Oracle Linux
Dec 30, 2021
How to install Nextcloud on Ubuntu 22.04 version
How to install Nextcloud on Ubuntu 22.04 version
Jun 23, 2023
How To Install PostgreSQL 10 on CentOS7
How To Install PostgreSQL 10 on CentOS7
Feb 26, 2018

Related Forums in How To Install and Create DB/User In PostgreSQL on Rocky Linux 8.6

Related Forums in How To Install and Create DB/User In PostgreSQL on Rocky Linux 8.6

Linux
jayce class=
shasum command not found
May 5, 2017
Linux
stephan class=
How to list all samba users
Jan 12, 2018
pv command
muhammad class=
pvcreate command not found error
May 9, 2017
Linux
henry class=
Starting NFS daemon: rpc.nfsd: writing fd to kernel failed: errno 111 (Connection refused)
Apr 25, 2017
ifconfig command
jackbrookes class=
what is the location of the ifconfig program on your machine?
Jan 4, 2018
Linux
baseer class=
single command to apply setfacl for multiple user at a time
Jan 23, 2018
Linux
beulah class=
What does mean by 0 0 value in fstab file
Jan 2, 2018
CentOS
mason class=
Error getting authority: Error initializing authority: Could not connect: No such file or directory (g-io-error-quark, 1)
Nov 20, 2018

Related News in How To Install and Create DB/User In PostgreSQL on Rocky Linux 8.6

Related News in How To Install and Create DB/User In PostgreSQL on Rocky Linux 8.6

Anbox, the Android-to-Linux tool the developers have been waiting for
Anbox, the Android-to-Linux tool the developers have been waiting for
Apr 17, 2017
Linus Torvalds stops signing Linux kernel RC tarballs
Linus Torvalds stops signing Linux kernel RC tarballs
May 17, 2017
Capsule8 Launches Linux-Based Container Security Platform
Capsule8 Launches Linux-Based Container Security Platform
Feb 14, 2017
Symantec updates Management console product
Symantec updates Management console product
Nov 22, 2017
Latest Linux driver release feature seven AMD Vega
Latest Linux driver release feature seven AMD Vega
Mar 23, 2017
A Newer and a Faster Window Manager for Tina (Linux Mint 19.2)
A Newer and a Faster Window Manager for Tina (Linux Mint 19.2)
Apr 9, 2019
Microsoft makes its Azure App service now available on Linux Systems
Microsoft makes its Azure App service now available on Linux Systems
Sep 7, 2017
Docker friendly Alpine Linux gets hardened Node.js
Docker friendly Alpine Linux gets hardened Node.js
Apr 19, 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 Owen ?
How to add SSH key to my Gitlab account

I need to add the SSH key in my gitlab account. How to do so ????

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.