News
Faster Speeds: Bandwidth for vStack Servers in Kazakhstan Increased to 200 Mbps
JH
Joe Harris
December 30 2020
Updated June 27 2025

How to Install and Configure PostgreSQL 13 on CentOS 8

CentOS Databases Linux

Using another OS?

Select the desired version or distribution.

In this comprehensive tutorial, we will guide you step-by-step through the installation and initial configuration of PostgreSQL 13 on CentOS 8. PostgreSQL 13 is a robust, open-source relational database management system known for its reliability and advanced features. Official updates and support for PostgreSQL 13 will continue until November 2025, ensuring long-term stability and security for your database environment. To perform the installation and configuration correctly, you must run all commands with root privileges or use sudo. This guide will help you get PostgreSQL 13 up and running smoothly on your CentOS 8 server, covering everything from repository setup to service management and basic database initialization.

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/repo-rpms/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

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=>

Conclusion

In this tutorial, you learned how to install and perform the initial configuration of PostgreSQL 13 on CentOS 8. We covered adding the official PostgreSQL repository, disabling older module versions, installing the server, initializing the database, and enabling the service to start automatically. Additionally, you saw how to secure the default postgres user with a password, create new system and database users, and log in to the PostgreSQL shell. Following these steps ensures a stable and secure PostgreSQL setup ready for your applications. PostgreSQL 13’s long-term support until November 2025 makes it a reliable choice for your database needs.

FAQ

  • Q: What are the system requirements for installing PostgreSQL 13 on CentOS 8?
    A: PostgreSQL 13 runs on standard CentOS 8 installations. You need root or sudo privileges and a stable internet connection to add repositories and download packages.
  • Q: How do I update PostgreSQL 13 on CentOS 8?
    A: Updates are delivered through the PostgreSQL repository you added. Use dnf update postgresql13-server to keep your server up to date.
  • Q: Can I install PostgreSQL 13 alongside older versions?
    A: It is not recommended to run multiple major PostgreSQL versions simultaneously on the same server unless carefully managed, as they use different data directories and ports.
  • Q: How do I enable remote access to PostgreSQL?
    A: You need to edit postgresql.conf to listen on the desired IP addresses and configure pg_hba.conf to allow remote connections. Don’t forget to restart the PostgreSQL service after changes.
  • Q: How do I secure my PostgreSQL installation?
    A: Set strong passwords for users, restrict network access using firewall rules, and configure PostgreSQL’s authentication methods properly.
  • Q: What if I want to uninstall PostgreSQL 13?
    A: Use dnf remove postgresql13-server to uninstall. Remember to back up your data before removing the server.
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

You might also like...

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.