How to Install PostgreSQL on Fedora 36 / Fedora 35 | Holhol24
PostgreSQL is a free object-relational database management system (ORDBMS). It is available for Linux, FreeBSD, Solaris, Microsoft Windows, and macOS.
PostgreSQL was developed by the PostgreSQL Global Development Group and released under the PostgreSQL License.
Here, we will see how to install PostgreSQL on Fedora 36 / Fedora 35.
Install PostgreSQL on Fedora 36
Setup PostgreSQL repository
PostgreSQL development group offers packages through a dedicated repository for all Linux platforms, and the packages are fresher than those available in the OS repositories. So, configure the PostgreSQL repository by installing the PostgreSQL repository package.
# Fedora 36 sudo dnf install -y https://download.postgresql.org/pub/repos/yum/reporpms/F-36-x86_64/pgdg-fedora-repo-latest.noarch.rpm # Fedora 35 sudo dnf install -y https://download.postgresql.org/pub/repos/yum/reporpms/F-35-x86_64/pgdg-fedora-repo-latest.noarch.rpm
Install PostgreSQL
When writing this post, PostgreSQL v14,13,12,11, and 10 are available for Fedora. You can install a specific version of PostgreSQL mentioning postgresql
in the dnf
command.
For example, to install PostgreSQL 14, use the below command.
sudo dnf install -y postgresql14-server
Initialize PostgreSQL Server
After installing PostgreSQL, you will need to initialize it before using it for the first time. Change the below command based on the PostgreSQL version /usr/pgsql-
.
sudo /usr/pgsql-14/bin/postgresql-14-setup initdb
PostgreSQL data is typically found /var/lib/pgsql/
directory.
After initializing the PostgreSQL database, start the PostgreSQL service and enable it on system startup.
sudo systemctl enable --now postgresql-14
Finally, check the status of the PostgreSQL service.
sudo systemctl status postgresql-14
Access PostgreSQL server
To create a database, log in as postgres
(Linux user) and then access the database using the psql
command. PSQL is an interactive terminal for working with the PostgreSQL database.
$ sudo su -l postgres $ psql
Output:
psql (14.4) Type "help" for help. postgres=#
Set password for postgres
(Database administrator) user.
postgres=# \password
Conclusion
That’s All. I hope you have learned how to install PostgreSQL on Fedora 36 / Fedora 35.