PostgreSQL is a powerful, open-source object-relational database system that has earned a strong reputation for its reliability, feature robustness, and performance. If you’re using Oracle Linux and need a reliable database solution, this step-by-step guide will help you how to install PostgreSQL on Oracle Linux system. Additionally, we’ll discuss some valuable resources to help you with other Oracle Linux-related tasks.
Before proceeding with the installation, ensure you have:
- A running Oracle Linux 7 or 8 system
- Root or sudo access to the system
How to Install PostgreSQL on Oracle Linux
Update Your System
First, update your system to ensure you’re working with the latest packages and security updates. Open a terminal and enter the following command:
sudo yum update -y
Install the PostgreSQL Repository on Oracle Linux
In this step, we will install the PostgreSQL repository, which contains the PostgreSQL packages. Enter the following command to install the repository:
sudo yum install -y https://download.postgresql.org/pub/repos/yum/reporpms/EL-8-x86_64/pgdg-redhat-repo-latest.noarch.rpm
Installing PostgreSQL on Oracle Linux
Now, install PostgreSQL by running the following command:
sudo yum install -y postgresql13 postgresql13-server
13 with the desired version number if you prefer a different version of PostgreSQL.
Initialize the PostgreSQL Database
After installing PostgreSQL, initialize the database with the following command:
sudo /usr/pgsql-13/bin/postgresql-13-setup initdb
13 with the desired version number if you’ve chosen a different version.
Enable and Start the PostgreSQL Service
Enable the PostgreSQL service to start automatically on system boot:
sudo systemctl enable postgresql-13
Start the PostgreSQL service:
sudo systemctl start postgresql-13
To allow remote connections to the PostgreSQL server, edit the
sudo vim /var/lib/pgsql/13/data/pg_hba.conf
Add the following line at the end of the file, replacing
YOUR_IP_ADDRESS with the IP address of the remote host you want to allow access:
host all all YOUR_IP_ADDRESS/32 md5
Save and exit the file. Next, edit the
sudo vim /var/lib/pgsql/13/data/postgresql.conf
Find the line that starts with
#listen_addresses = 'localhost' and change it to:
listen_addresses = '*'
Save and exit the file. Finally, restart the PostgreSQL service for the changes to take effect:
sudo systemctl restart postgresql-13
Create a PostgreSQL User and Database
Switch to the
sudo su - postgres
Enter the PostgreSQL command prompt:
Create a new user and database, replacing
your_password with your desired username and password:
CREATE USER your_user WITH ENCRYPTED PASSWORD 'your_password'; CREATE DATABASE your_database WITH OWNER your_user;
Grant all privileges to the new user:
GRANT ALL PRIVILEGES ON DATABASE your_database TO your_user;
Exit the PostgreSQL command prompt by typing
\q and pressing Enter. Finally, switch back to your original user by typing
exit and pressing Enter.
That’s it! You have successfully installed and configured
PostgreSQL on your Oracle Linux system. You can now connect to the PostgreSQL server remotely using the newly created user and database.
Additional Oracle Linux Resources
For further assistance with Oracle Linux-related tasks, check out the following resources:
- How to Install VirtualBox on Oracle Linux
- How to Set Up a BIND DNS Server on Oracle Linux
- How to Install KVM on Oracle Linux
- How to Install Ansible on Oracle Linux
- How to Install LAMP Stack on Oracle Linux
These resources will help you expand your knowledge and improve your Oracle Linux server management skills.
In this comprehensive guide, we have covered the steps required to install PostgreSQL on Oracle Linux. This powerful, open-source database system offers a robust and reliable solution for your data storage needs. With this knowledge, you can now proceed to use PostgreSQL for your applications and manage your Oracle Linux server effectively. Remember to explore the additional resources listed above for more in-depth guidance on various Oracle Linux-related tasks.