Database Installation in Linux

Postgre Installation in Red Hat & Cent OS

Installing postgre sql installation in redhat / Cent OS linux

Step 1 — Installing PostgreSQL

Postgres can be installed using default CentOS repositories. But as of the writing of this tutorial, the version that is available in the CentOS 7 Base repository is obsolete. Therefore, this tutorial will use the official Postgres repository.

Before you move on to setting up a new repository, exclude the search for postgresql packages from the CentOS-Base repository. Otherwise, dependencies might resolve to the postgresql supplied by the base repository.

Open the repository configuration file using your preferred text editor.

sudo nano /etc/yum.repos.d/CentOS-Base.repo

Find the [base] and [updates] sections, enter insert mode by pressing i, and insert the exclude=postgresql* line in both sections. As a result, your file will look like the following, with new lines highlighted:

Add the exclude Highlighted Line under Base and Updates Section

Now, install a repository configuration package using the official PostgreSQL repository for CentOS

sudo yum install https://download.postgresql.org/pub/repos/yum/reporpms/EL-7-x86_64/pgdg-redhat-repo-latest.noarch.rpm

The PostgreSQL repository includes information for all available PostgreSQL releases. You can see all available packages and versions using the following command

yum list postgresql* it will show all the packages can be installed related to postgresql

To install the PostgreSQL server use the following command

During the installation Import GPG Key will be prompt hit Y

Step 2 — Creating a New PostgreSQL Database Cluster

You have to create a new PostgreSQL database cluster before you can use your Postgres database. A database cluster is a collection of databases that are managed by a single server instance. Creating a database cluster consists of creating the directories in which the database data will be placed, generating the shared catalog tables, and creating the template1 and postgres databases

The template1 database is needed to create a new database. Everything that is stored in it will be placed in a new database when it is created. A postgres database is a default database designed for use by users, utilities, and third-party applications.

Create a new PostgreSQL database cluster with initdb

sudo /usr/pgsql-11/bin/postgresql-11-setup initdb

Output of the Command

Enable and Start the Postgresql service

Step 3 — Using PostgreSQL Roles and Databases

Switching Over to the postgres Account

After this Type psql

You will be prompted to the psql prompt

Bingo !

To Exit out of the Prompt and Return to your bash shell

Done :)

--

--

--

Trying To learn as much as possible about different Techonology. About me I am just a normal Boy who lives in terminal

Love podcasts or audiobooks? Learn on the go with our new app.

Recommended from Medium

Wordpress Performance

Core Java Interview Questions for Beginners

Code Cooking: Kubernetes

How to organize the learning process with mindmaps, spreadsheets, and .NET Core

Open-Source Needs a Reckoning

Creating a Wildlife Camera With a Raspberry PI, Python OpenCV and Tensorflow

Setting up a Raspberry Pi to show DataDog stats on TV

Creating A Simple API Using Flask In Python

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Sourabh Dey

Sourabh Dey

Trying To learn as much as possible about different Techonology. About me I am just a normal Boy who lives in terminal

More from Medium

Running SQL Server in Linux containers on Windows using Docker Compose

SSMS

Run Docker Inside Docker

Accessing Docker tag as an environment variable inside a Docker container project

Docker Introduction