PostgreSQL or Postgres is a free and open-source cross-platform relational database management system. It is a robust, extensible, and technical standard-compliant database management system.
PostgreSQL is a successor of the Ingres database developed at UC Berkley in 1996. It is designed to handle simple to more complex tasks and can be used on a single computer to Dataware houses with many concurrent users.
In this article, I will discuss installing and configuring PostgreSQL in Fedora Linux.
Prerequisites
To follow this guide you should have the following –
- A system running a recent version of Fedora Linux
- Access to a user account with root privileges
- Working internet connection for downloading required packages
How to install PostgreSQL in Fedora
We will install PostgreSQL on Fedora from its official package repository. But before that, you need to add the PostgreSQL package repository to your system.
Use the given command to add the PostgreSQL package repository –
sudo dnf install -y https://download.postgresql.org/pub/repos/yum/reporpms/F-36-x86_64/pgdg-fedora-repo-latest.noarch.rpm
Refresh the package repository list on your system –
sudo dnf update -y
Finally, use the given command to install PostgreSQL on a Fedora system –
sudo dnf install postgresql14-server -y
Initialize database
Before you start using PostgreSQL first initialize the database.
Use the following command to initialize –
sudo /usr/pgsql-14/bin/postgresql-14-setup initdb
Start and enable PostgreSQL services
Use the following command to enable PostgresSQL services so that it get starts automatically when you reboot your system –
sudo systemctl enable postgresql-14
Next, use the given command to start the PostgreSQL service if not started yet –
sudo systemctl start postgresql-14
Check PostgreSQL version
You can check the install PostgreSQL version by using the given command –
psql -V
Start using the PostgreSQL server
You can now connect to the PostgreSQL server to create and manage databases. By default, PostgreSQL creates a special user called postgres that has all permissions.
Use the given command to log in to this account –
sudo su postgres
Now use the given command to access the PostgreSQL shell –
psql
This will change your prompt as you can see in the image below –
You can check the list of existing databases by using –
\l
Set the postgres user password –
\password
Use the following to view the list of SQL commands –
\h
OR use the given command to view psql commands –
\?
Conclusion
So you have successfully installed and configured PostgreSQL on your Fedora system.
For more details, you can follow its official documentation.
Now for any queries or feedback, you can write us in the comments below.