How to Install PostgreSQL 14 on Fedora 35 Server
PostgreSQL also known as Postgres,
is a free and open source object-relational database system (RDBMS)
emphasizing extensibility and SQL compliance. PostgreSQL has been in
active development for over 30 years and has earned a strong reputation
in its reliability, robustness, and performance.
The PostgreSQL Global Development Group (PGDG) had announced the release of PostgreSQL 14.1 a while ago.
This new release of PostgreSQL 14 comes with several new features
designed to ease administration and development of intense data-driven
applications. Some of the improvements are in complex data types
support, logical replication, connection concurrency, query parallelism,
and high-write workloads among many other features and improvements.
This guide will show you how to quickly get PostgreSQL 14.1 up and running on an Fedora 35 system.
Install PostgreSQL 14 on Fedora 35 Server
Most Linux distributions have PostgreSQL available at their respective repositories, including Fedora. Let's check which version is available in their repository.
$ sudo dnf info postgresql-server
In my system, it responds like below:
can see that the latest available version is 13.4. This means
installation from Fedora's official repository is not an option.
Luckily, PGDG has its own repository for most common distributions. For Fedora (and other RedHat family), it's called PostgreSQL Yum Repository.
Note: I'm using 64-bit architecture. Most of recent systems are using 64-bit architecture. If you're not sure what version you're running, run
lspcicommand. If you're running 32-bit, then adjust as necessary.
Add the PostgreSQL Yum Repository to Fedora
We need to add the PostgreSQL yum Repository to our Fedora 35 system. We can
accomplish this from the terminal to add the file (make sure to use
sudo in all of the following steps):
$ sudo dnf install -y https://download.postgresql.org/pub/repos/yum/reporpms/F-35-x86_64/pgdg-fedora-repo-latest.noarch.rpm
PostgreSQL 14 Installation
Once the PostgreSQL repository is added to your Fedora system, install PostgreSQL 14 Server and Client packages:
$ sudo dnf install -y postgresql14-server postgresql14
Please note that this can be a long process, depends on your internet connection and how frequent you're upgrading your packages.
After installation, we need to continue with post-install tasks.
To initialize PostgreSQL database, enter this command:
$ sudo /usr/pgsql-14/bin/postgresql-14-setup initdb
Enable Automatic Start
To enable automatic start PostgreSQL at boot, add PostgreSQL service to systemd.
$ sudo systemctl enable postgresql-14
Start PostgreSQL Service
Finally, to start PostgreSQL service, run this command:
$ sudo systemctl start postgresql-14
Verify PostgreSQL Installation
Let's verify that we've installed PostgreSQL correctly. First we'll check if the service is running. Then we can check what version of PostgreSQL server is running.
$ sudo systemctl status postgresql-14
If your installation is correct, you should see something like below:
We can use the
psql tool to connect with the PostgreSQL database server and printing its version:
$ psql --version
The output will be something like this:
psql (PostgreSQL) 14.1. That’s it. You've successfully installed PostgreSQL 14.1 to your Fedora system and you can start using it.
Configuring Postgres for Use
The postgres user
While PostgreSQL become installed, a system user account named
postgres was also created with an identical user account in postgres. By default, the
user account isn't configured with a password, so it isn't viable to
log into the server the use of the postgres user account without first
creating a password for it. This
postgres account has an all-access pass on your PostgreSQL database server, permission-wise. The
postgres user account has similarities to the
sa account in SQL server.
The postgres database
PostgreSQL is installed with a default database
postgres. For the most part, we use the
postgres database for administration functions, and create new databases on the PostgreSQL server to suit our needs.
The psql Command Line Utility
PostgreSQL consists of
psql, a command line application for managing your databases and server. While a GUI-based software such as
pgadmin4 is often less complicated to use in the daily task, the command line utilty
psql is always handy.
psql gives total control of your postgres system from the terminal, together with the ability to execute SQL queries.
We will use
psql to perform our preliminary configuration and to create an initial database super user.
Create super user account
In this step we will super-user account to deals with our database in the daily task.
To do this, we will get access to the
postgres account through your system
root user. Then we'll use that
account to create a brand new super-user account for your PostgreSQL
installation which can be regulated more efficiently. As an example we
steven as our new PostgreSQL super-user account.
$ sudo su -
# su - postgres
Type "help" for help.
postgres=# CREATE USER steven
postgres-# WITH SUPERUSER CREATEDB CREATEROLE
postgres-# PASSWORD 'youshouldknowwhattodohere';
Notice in the above we can enter multiple lines of command in SQL shell. The SQL is not executed until semi-colon followed enter is found. Which means, the semi-colon will make the shell execute entered commands. After pressing "Enter" it will respond with something like this:
Which means we've successfully created this new superuser account.
Login using our newly created account
Let's verify that everything is working correctly. Try to log in with
psql using our new super-user account and create a quick test database:
$ psql -h localhost -U steven postgres
Password for user steven:
Type "help" for help.
Note in the above terminal session, we specified the
postgres default database when we logged in, since there aren’t yet any other databases to connect to.
Create test database
Next test is to create test database
test_database using our new super-user account:
postgres=# CREATE DATABASE test_database WITH OWNER steven;
postgres=# \connect test_database;
You are now connected to database "test_database" as user "steven".
I hope that you now know how to install PostgreSQL 14.1 on Fedora 35. If you run into any issues or have any feedback feel free to drop a comment below.