How to Install PostgreSQL on Fedora 37 / Fedora 36
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 37 / Fedora 36.
Install PostgreSQL on Fedora 37
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 35 sudo dnf install -y https://download.postgresql.org/pub/repos/yum/reporpms/F-37-x86_64/pgdg-fedora-repo-latest.noarch.rpm # Fedora 36 sudo dnf install -y https://download.postgresql.org/pub/repos/yum/reporpms/F-36-x86_64/pgdg-fedora-repo-latest.noarch.rpm
Install PostgreSQL
When writing this post, PostgreSQL v15, 14, 13, 12, and 11 are available for Fedora. You can install a specific version of PostgreSQL with dnf install -y postgresql<version>-server
command.
For example, to install PostgreSQL 15, use the below command.
sudo dnf install -y postgresql15-server
Initialize PostgreSQL Server
After installing PostgreSQL, you must initialize it before using it for the first time. Change the below command based on the version of PostgreSQL/usr/pgsql-<version>/bin/postgresql-<version>-setup initdb
.
sudo /usr/pgsql-15/bin/postgresql-15-setup initdb
PostgreSQL data is typically found /var/lib/pgsql/<version>/data/
directory.
After initializing the PostgreSQL database, start and enable the service on system startup.
sudo systemctl enable --now postgresql-15
Finally, check the status of the PostgreSQL service.
sudo systemctl status postgresql-15
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 (15.2) 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 37 / Fedora 36.