Introduction

PostgreSQL is a powerful, open-source object-relational database system that uses and extends the SQL language. This guide provides a detailed walkthrough for installing PostgreSQL on AlmaLinux 9, ensuring you can manage your data effectively. This setup can also be beneficial when combined with a Windows VPS UK for enhanced performance and reliability.

Prerequisites

  • An AlmaLinux 9 server with root access
  • Internet connection for downloading packages
  • Basic knowledge of command-line operations

Step 1: Update the System

Begin by updating your system to ensure all packages are current. Run the following command:

sudo dnf update -y

Step 2: Install PostgreSQL Repository

To install PostgreSQL, you need to enable the PostgreSQL repository. Run the following command to install the necessary repository package:

sudo dnf install -y https://download.postgresql.org/pub/repos/yum/reporpms/EL-9-x86_64/pgdg-redhat-repo-latest.noarch.rpm

Step 3: Disable the Built-in PostgreSQL Module

AlmaLinux may come with a built-in PostgreSQL module. Disable it using the command:

sudo dnf -qy module disable postgresql

Step 4: Install PostgreSQL

Now that the repository is set up, you can install PostgreSQL. Use the following command:

sudo dnf install -y postgresql15 postgresql15-server

Step 5: Initialize PostgreSQL Database

After the installation, initialize the PostgreSQL database using the following command:

sudo /usr/pgsql-15/bin/postgresql15-setup initdb

Step 6: Start and Enable PostgreSQL Service

Now, start the PostgreSQL service and enable it to run on boot:

sudo systemctl start postgresql-15
sudo systemctl enable postgresql-15

Step 7: Configure PostgreSQL to Accept Remote Connections

By default, PostgreSQL only allows local connections. To enable remote access, edit the pg_hba.conf file:

sudo nano /var/lib/pgsql/15/data/pg_hba.conf

Add the following line to allow connections from all IP addresses:

host all all 0.0.0.0/0 md5

Next, edit the postgresql.conf file:

sudo nano /var/lib/pgsql/15/data/postgresql.conf

Find the line that starts with listen_addresses and modify it to:

listen_addresses = '*'

Step 8: Restart PostgreSQL Service

After making these changes, restart the PostgreSQL service:

sudo systemctl restart postgresql-15

Step 9: Create a PostgreSQL User

Log into PostgreSQL and create a new user:

sudo -u postgres psql
CREATE USER your_username WITH PASSWORD 'your_password';

Replace your_username and your_password with your desired credentials.

Step 10: Conclusion

Congratulations! You have successfully installed PostgreSQL on AlmaLinux 9. This powerful database system is now ready to be used for your applications. For enhanced performance and reliable hosting, consider using a Windows VPS. Explore options such as VPS UK Windows, including Windows Virtual Private Server Hosting and Windows VPS Hosting UK for your database solutions.

© 2024 PostgreSQL Installation Tutorial. All rights reserved.

¿Fue útil la respuesta? 0 Los Usuarios han Encontrado Esto Útil (0 Votos)