News
Seven days of Black Friday madness — great deal from Serverspace!

THE NEW YEAR
WHEEL OF FORTUNE

Spin the wheel and win a guaranteed prize right now!

By registering, you are signing up to receiving emails.
JH
Joe Harris
December 30 2020
Updated December 11 2024

How to Install PostgreSQL 13 on CentOS 8

CentOS Databases Linux

Using another OS?

Select the desired version or distribution.

In this tutorial, we'll walk you through the installation and initial configuration of PostgreSQL 13 on CentOS 8. Updates for PostgreSQL 13 will be released for five years through November 2025. You must run all commands as root.

In the Serverspace you can create a server with already installed app "PostgreSQL".

Installing PostgreSQL 13 packages

Add PostgreSQL repository to the system.

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

Turn off the PostgreSQL modules with an older version present in the system.

dnf -qy module disable postgresql

Let’s install PostgreSQL 13 server.

dnf install -y postgresql13-server

Initial configuration

Initialize the database.

/usr/pgsql-13/bin/postgresql-13-setup initdb
Initializing database ... OK

Start and enable autostart of the PostgreSQL service.

systemctl enable --now postgresql-13

Set a password for the postgres user.

su - postgres
psql -c "alter user postgres with password 'psql-user-pass'"
ALTER ROLE
exit
logout

Creating a new PostgreSQL user

To create a new user in PostgreSQL, you first need to create it in the system itself.

adduser username
passwd username

Log in as postgres.

su - postgres

Create a database user.

createuser username

Create a database for this user.

createdb username

The new user can now work with PostgreSQL. Let’s log in. Enter username’s password when prompted.

su - username
Password:

Enter the PostgreSQL command line.

psql
psql (13.1)
Type "help" for help.
username=>

Vote:
3 out of 5
Аverage rating : 3.8
Rated by: 12
1101 CT Amsterdam The Netherlands, Herikerbergweg 292
+31 20 262-58-98
700 300
ITGLOBAL.COM NL
700 300
We use cookies to make your experience on the Serverspace better. By continuing to browse our website, you agree to our
Use of Cookies and Privacy Policy.