
PostgreSQL is an open-source Relational Database Management System (RDBMS) that supports complex data types, ACID-compliant transactions. The RDBMS is widely used in web applications, data warehousing, and geospatial data management. PostgreSQL supports Structured Query Language (SQL) for storing and retrieving data in tables.
This article explains how to install PostgreSQL on Rocky Linux 9 and how to enable authentication for database users.
Before you begin:
PostgreSQL is available in the default package repositories on Rocky Linux 9. Follow the steps below to install the latest PostgreSQL database server package using the dnf package manager.
Update the server's package information index.
List all available PostgreSQL packages.
Output:
Based on the above output, PostgreSQL 13 is the latest version available in the Rocky Linux 9 repository sources.
Install the PostgreSQL database server package.
PostgreSQL uses the postgresql system service to manage the database server runtime and processes on Rocky Linux 9. Follow the steps below to enable the PostgreSQL database server to automatically start at system boot and verify the service processes.
Enable the PostgreSQL service to automatically start at boot.
Output:
Initialize the PostgreSQL database server to enable the default postgres user.
Output:
Start the PostgreSQL service.
View the PostgreSQL service status and verify that it's active.
Output:
PostgreSQL runs with a default postgres administrative database user account that requires no password. Follow the steps below to set up password authentication for the postgres user and create standard users on PostgreSQL.
Log in to the PostgreSQL database server as the postgres user.
Modify the postgres user to use a new strong password. Replace strong_password with your desired password.
Create a sample db_admin database user and set a strong password for the user.
Exit the PostgreSQL console
Back up the main pg_hba.conf PostgreSQL configuration file.
Open the pg_hba.conf file using a text editor like Nano.
Find the following configuration section within the file.
Change the peer value to md5 to enable password authentication.
Save and close the file.
Restart the PostgreSQL service to apply the configuration changes.
You can access the PostgreSQL database server console using the psql client utility that ships with the database server package. Follow the steps below to access the PostgreSQL database server console and perform database operations.
Create a sample example-vultr database and assign the database to the db_admin user.
Enter the postgres user password you set earlier when prompted.
Log in to the PostgreSQL database server as the db_admin user to test access to the example-vultr database.
Enter the db_admin user password you created earlier when prompted.
Create a sample shop table.
Insert sample data into the shop table.
Query the shop table to view all available sample records.
Output:
Exit the PostgreSQL database server console.
You have installed PostgreSQL on Rocky Linux 9 and enabled password authentication to allow users to securely access the database console. You can integrate PostgreSQL with graphical management tools such as PGAdmin and install specific application modules to use the database server with other applications. For more information and configuration options, visit the PostgreSQL documentation.
0 Comments
Be the first to comment and share your perspective with the community.