EDUCBA

EDUCBA

MENUMENU
  • Free Tutorials
  • Free Courses
  • Certification Courses
  • 360+ Courses All in One Bundle
  • Login

Install PostgreSQL

Home » Data Science » Data Science Tutorials » PostgreSQL Tutorial » Install PostgreSQL

Install PostgreSQL

Introduction to Install PostgreSQL

PostgreSQL is an object-relational database management system; it is an open-source database management system that is not owned or controlled by any one company or individual person, it is managed by online community developers also by other volunteers; PostgreSQL database software first released in the mid of 1990, PostgreSQL database software was written in C language, PostgreSQL primary competitors database like MySQL, MSSQL and Oracle DB, PostgreSQL was supporting all database feature and also support MVCC (Multi-version concurrency control) architecture.

Prerequisites for PostgreSQL installation

The following are the prerequisites for PostgreSQL.

Start Your Free Data Science Course

Hadoop, Data Science, Statistics & others

1. PostgreSQL on windows; we need to have superuser privileges on MAC, UNIX or Linux system. To install it on windows, we need to have administrator privileges.

2. To install this on windows, we need to enabled or configured user account control (UAC).

3. We need to have superuser privileges to install it on Linux.

4. Before installing PostgreSQL on the system that we have run an SELinux, We must set it to SELinux on permissive mode.

5. Please find below the example to set SELinux permissive in different environments.

Popular Course in this category
PostgreSQL Course (2 Courses, 1 Project)2 Online Courses | 1 Hands-on Project | 7+ Hours | Verifiable Certificate of Completion | Lifetime Access
4.5 (2,948 ratings)
Course Price

View Course

Related Courses
  • Before installing PostgreSQL, we need to set SELinux on permissive please find below command for the same.

$ setenforce permissive

  • After installing PostgreSQL, we need to set SELinux on enforcing mode; please find the below command.

$ Setenforce enforcing

6. We need to install xterm, Konsole or genome terminal before executing a console-based program by the PostgreSQL enterprise DB installer.

7. For the Windows operating system, we need to update the OS before installing PostgreSQL software. If an error occurred in the middle, we need to exit and update the OS version to the latest operating system version.

8. We need to have RPM (Red hat package manager) of the PostgreSQL database to install it on Linux like systems.

9. We need to have download PostgreSQL RPM packages from PostgreSQL official website.

Steps to Install PostgreSQL on CentOS

Let us discuss the procedure to install PostgreSQL in detail.

Step 1

We have using CentOS version 7.7 to install PostgreSQL.

Below is the command to check the CentOS version:

# cat /etc/Redhat-release

Output:

Install PostgreSQL - CentOS version

Step 2

Edit CentOS base repo (Repository file) to install PostgreSQL DB

  • We have using the CentOS base repository to install PostgreSQL on CentOS. We need to exclude the search of PostgreSQL from the repository for installing it from the base repository.
  • Then open the repository file using vi or vim; we have using vi to edit the below file.
  • The file finds the base and updates section in the repository and inserts it by pressing “i” after opening and repository file.
  • Then we need to insert “Exclude = PostgreSQL* in both sections after saving the file using ESC + “wq”.

vi /etc/yum.repos.d/CentOS-Base.repo
[base] name = CentOS-$releasever - Base
mirrorlist =http://mirrorlist.centos.org/?release=$releasever&arch
=$basearch&repo=os&infra=$infra
baseurl = http://mirror.centos.org/centos/$releasever/os/$basearch/
Gpgcheck = 1
Gpgkey = file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7
Exclude = postgresql*
released updates
[updates] Name = CentOS-$releasever - Updates
Mirrorlist = http://mirrorlist.centos.org/?release=$releasever&arch
=$basearch&repo=updates&infra=$infra
baseurl = http://mirror.centos.org/centos/$releasever/updates/$basearch/
Gpgcheck = 1
Gpgkey = file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7
Exclude = postgresql*

Output:

Install PostgreSQL - Exclude postgresql

Step 3

Then we need to install the repository configuration package by using the official PostgreSQL repository for CentOS.

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

After executing the above command, the process will prompt, then we confirm the installation by pressing key “Y”.

Output:

Install PostgreSQL - command

Step 4

Then we list all packages and versions by using the following command. It will show all the PostgreSQL desired versions. We desire a PostgreSQL 11 version.

yum list PostgreSQL*

Output:

desired versions 1

desired versions 2

Step 5

Install PostgreSQL on CentOS by using the following command.

  • We need to install the PostgreSQL client and PostgreSQL server to install the PostgreSQL database.
  • Also, we need to install the PostgreSQL libs package for resolving dependency to install the PostgreSQL DB server.
  • For installing this, we need to install the below package as follows.
  1. Postgresql 11 server
  2. Postgresql 11
  3. Postgresql 11 libs
  • PostgreSQL 11 and Postgresql 11 libs are dependency packages to install the PostgreSQL DB server.

yum install postgresql11-server

Output:

PostgreSQL DB server 1

PostgreSQL DB server 2

Step 6

After installation, we need to initialize steps to create a new database cluster of the PostgreSQL database.

  • We need to create a PostgreSQL database cluster before using the database.
  • PostgreSQL cluster is nothing but the collection of databases that was managed by a single server instance.
  • Creating of database cluster will create a new physical file of data directory and database files.
  • It will also create catalog tables and creates template 0, template 1 and Postgres database.
  • Template 0 and template 1 database is used to create a new database for the user.
  • Postgres database is a default database for connections of administrative users and application users.
  • Below is the command to initialize the PostgreSQL database cluster are as follows.
  • The below command will initialize the database, and database files also initialize the administrative database.

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

Output:

initialize database

Step 7

Now we need to enable and start the PostgreSQL service by using systemctl command.

systemctl start postgresql-11
systemctl enable PostgreSQL-11

Output:

PostgreSQL service

Step 8

Log in to the PostgreSQL database by using the default authentication method.

  • Default PostgreSQL database uses roles to handle the authentication and authorization.
  • It default uses an ident authentication method to authenticate the database with users.
  • It will manage OS authentication with database users.
  • The procedure creates OS level and DB level user by default; it will access the database the first time with the ident authentication method.
  • Below is the authentication method available in PostgreSQL.
  1. MD5
  2. Ident
  3. Peer
  4. LDAP
  5. Trust
  6. Kerberos
  • Below is the process to access the PostgreSQL database for the first time.

 Login to PostgreSQL database

Conclusion

It is an open-source database management system. It is also an object-relational database management system. A single company or person does not manage the PostgreSQL database; it has managed by community developers or other volunteers. It is most popular in the relational database management system.

Recommended Articles

This is a guide to Install PostgreSQL. Here we discuss Prerequisites and Steps to Install PostgreSQL on CentOS along with appropriate examples. You can also go through our other suggested articles to learn more –

  1. PostgreSQL Data Types
  2. PostgreSQL Operators
  3. NOT in MySQL
  4. PostgreSQL WHERE Clause

PostgreSQL Course (2 Courses, 1 Project)

2 Online Courses

1 Hands-on Project

7+ Hours

Verifiable Certificate of Completion

Lifetime Access

Learn More

0 Shares
Share
Tweet
Share
Primary Sidebar
PostgreSQL Tutorial
  • Basic
    • What is PostgreSQL
    • PostgreSQL Features
    • How to Install PostgreSQL
    • PostgreSQL Versions
    • PostgreSQL Architecture
    • PostgreSQL GUI
    • PostgreSQL Variables
    • PostgreSQL Data Types
    • PostgreSQL NOT NULL
    • PostgreSQL Integer
    • PostgreSQL Boolean
    • PostgreSQL NULLIF
    • PostgreSQL Administration
    • PostgreSQL Commands
    • PostgreSQL Operators
    • PostgreSQL IN Operator
  • Control Statement
    • PostgreSQL IF Statement
    • PostgreSQL if else
    • PostgreSQL CASE Statement
    • PostgreSQL LOOP
    • PostgreSQL For Loop
    • PostgreSQL While Loop
  • Joins
    • Joins in PostgreSQL
    • PostgreSQL Inner Join
    • PostgreSQL Outer Join
    • LEFT OUTER JOIN in PostgreSQL
    • PostgreSQL FULL OUTER JOIN
    • PostgreSQL LEFT JOIN
    • PostgreSQL Full Join
    • PostgreSQL Cross Join
    • PostgreSQL NATURAL JOIN
    • PostgreSQL UPDATE JOIN
  • Queries
    • PostgreSQL Queries
    • PostgreSQL WHERE Clause
    • PostgreSQL WITH Clause
    • PostgreSQL ORDER BY
    • PostgreSQL ORDER BY Random
    • PostgreSQL GROUP BY
    • PostgreSQL group_concat
    • PostgreSQL HAVING
    • PostgreSQL Recursive Query
  • Advanced
    • PostgreSQL Schema
    • Postgres List Schemas
    • PostgreSQL VARCHAR
    • Array in PostgreSQL
    • PostgreSQL DDL
    • PostgreSQL List Users
    • Postgres Default User
    • Postgres add user
    • PostgreSQL log_statement
    • PostgreSQL String Functions
    • PostgreSQL Compare Strings
    • PostgreSQL Text Search
    • PostgreSQL TEXT
    • PostgreSQL String Array
    • PostgreSQL Constraints
    • PostgreSQL UNIQUE Constraint
    • PostgreSQL INTERSECT
    • PostgreSQL Like
    • Cursors in PostgreSQL
    • PostgreSQL UNION ALL
    • Indexes in PostgreSQL
    • PostgreSQL Index Types
    • PostgreSQL REINDEX
    • PostgreSQL UNIQUE Index
    • PostgreSQL Clustered Index
    • PostgreSQL DROP INDEX
    • PostgreSQL DISTINCT
    • PostgreSQL FETCH
    • PostgreSQL RAISE EXCEPTION
    • PostgreSQL Auto Increment
    • Sequence in PostgreSQL
    • Wildcards in PostgreSQL
    • PostgreSQL Subquery
    • PostgreSQL Alias
    • PostgreSQL LIMIT
    • PostgreSQL Limit Offset
    • PostgreSQL LAG()
    • PostgreSQL Table
    • Postgres Show Tables
    • PostgreSQL Describe Table
    • PostgreSQL Lock Table
    • PostgreSQL ALTER TABLE
    • Postgres Rename Table
    • Postgres DROP Table
    • PostgreSQL Functions
    • PostgreSQL Math Functions
    • PostgreSQL Window Functions
    • Aggregate Functions in PostgreSQL
    • PostgreSQL Primary Key
    • Foreign Key in PostgreSQL
    • PostgreSQL Procedures
    • PostgreSQL Stored Procedures
    • PostgreSQL Views
    • PostgreSQL Materialized Views
    • Postgres Create View
    • PostgreSQL Triggers
    • PostgreSQL DROP TRIGGER
    • PostgreSQL Date Functions
    • PostgreSQL TO_DATE()
    • PostgreSQL Timestamp
    • PostgreSQL CURRENT_TIMESTAMP()
    • PostgreSQL Notify
    • PostgreSQL RANK()
    • PostgreSQL Select
    • PostgreSQL Average
    • PostgreSQL DATE_PART()
    • PostgreSQL EXECUTE
    • PostgreSQL COALESCE
    • PostgreSQL EXTRACT()
    • PostgreSQL Sort
    • PostgreSQL TO_CHAR
    • PostgreSQL Interval
    • PostgreSQL Number Types
    • PostgreSQL ROW_NUMBER
    • Alter Column in PostgreSQL
    • PostgreSQL Identity Column
    • PostgreSQL SPLIT_PART()
    • PostgreSQL CONCAT()
    • PostgreSQL replace
    • PostgreSQL TRIM()
    • PostgreSQL MAX
    • PostgreSQL DELETE
    • PostgreSQL Float
    • PostgreSQL OID
    • PostgreSQL log
    • PostgreSQL REGEXP_MATCHES()
    • PostgreSQL MD5 
    • PostgreSQL NOW()
    • PostgreSQL RANDOM
    • PostgreSQL round
    • PostgreSQL Trunc()
    • PostgreSQL TIME
    • PostgreSQL IS NULL
    • PostgreSQL CURRENT_TIME
    • PostgreSQL MOD()
    • Postgresql Count
    • PostgreSQL Datetime
    • PostgreSQL MIN()
    • PostgreSQL age()
    • PostgreSQL enum
    • PostgreSQL OR
    • PostgreSQL Wal
    • PostgreSQL NOT IN
    • PostgreSQL SET
    • PostgreSQL Current Date
    • PostgreSQL Compare Date
    • PostgreSQL SERIAL
    • PostgreSQL Database
    • PostgreSQL Clone Database
    • PostgreSQL Copy Database
    • PostgreSQL Restore Database
    • PostgreSQL DROP DATABASE
    • PostgreSQL ALTER DATABASE
    • Postgres DROP Database
    • Postgres Dump Database
    • PostgreSQL OFFSET
    • PostgreSQL GRANT
    • PostgreSQL COMMIT
    • PostgreSQL ROLLUP
    • PostgreSQL JSON
    • EXPLAIN ANALYZE in PostgreSQL
    • PostgreSQL Temporary Table
    • PostgreSQL cluster
    • PostgreSQL Replication
    • PostgreSQL Logical Replication
    • PostgreSQL flush privileges
    • PostgreSQL Tablespaces
    • CAST in PostgreSQL
    • PostgreSQL CTE
    • hstore in PostgreSQL
    • PostgreSQL DECODE()
    • PostgreSQL Vacuum
    • PostgreSQL EXCLUDE
    • Postgres Change Password
    • Postgres Delete Cascade
    • PostgreSQL EXCEPT
    • PostgreSQL Roles
    • PostgreSQL Link
    • PostgreSQL Partition
    • PostgreSQL column does not exist
    • PostgreSQL Log Queries
    • PostgreSQL escape single quote
    • PostgreSQL Query Optimization
    • PostgreSQL Character Varying
    • PostgreSQL Transaction
    • PostgreSQL Extensions
    • PostgreSQL Import CSV
    • PostgreSQL Client
    • PostgreSQL caching
    • PostgreSQL JDBC Driver
    • PostgreSQL Interview Questions
Footer
About Us
  • Blog
  • Who is EDUCBA?
  • Sign Up
  • Corporate Training
  • Certificate from Top Institutions
  • Contact Us
  • Verifiable Certificate
  • Reviews
  • Terms and Conditions
  • Privacy Policy
  •  
Apps
  • iPhone & iPad
  • Android
Resources
  • Free Courses
  • Database Management
  • Machine Learning
  • All Tutorials
Certification Courses
  • All Courses
  • Data Science Course - All in One Bundle
  • Machine Learning Course
  • Hadoop Certification Training
  • Cloud Computing Training Course
  • R Programming Course
  • AWS Training Course
  • SAS Training Course

© 2020 - EDUCBA. ALL RIGHTS RESERVED. THE CERTIFICATION NAMES ARE THE TRADEMARKS OF THEIR RESPECTIVE OWNERS.

EDUCBA
Free Data Science Course

Hadoop, Data Science, Statistics & others

*Please provide your correct email id. Login details for this Free course will be emailed to you
Book Your One Instructor : One Learner Free Class

Let’s Get Started

This website or its third-party tools use cookies, which are necessary to its functioning and required to achieve the purposes illustrated in the cookie policy. By closing this banner, scrolling this page, clicking a link or continuing to browse otherwise, you agree to our Privacy Policy

EDUCBA

*Please provide your correct email id. Login details for this Free course will be emailed to you
EDUCBA Login

Forgot Password?

EDUCBA
Free Data Science Course

Hadoop, Data Science, Statistics & others

*Please provide your correct email id. Login details for this Free course will be emailed to you

Special Offer - PostgreSQL Course (2 Courses, 1 Project) Learn More