Creating a PostgreSQL Installation for Local Testing

This guide explains how to install PostgreSQL locally in a virtual machine for testing and development purposes.


Important

The following steps assume you have a virtual machine running AlmaLinux on your local computer. For instructions on setting up a virtual machine, see the relevant guide.


Installing PostgreSQL

  1. Start the virtual machine if it is not already running.

  2. Log in as the root user.

  3. Install PostgreSQL:

yum install postgresql-server postgresql-contrib

At the prompt, type y and press Enter to proceed with the installation.

  1. Initialize the PostgreSQL database:

postgresql-setup initdb
  1. Enable password authentication:

Edit the pg_hba.conf file:

vi /var/lib/pgsql/data/pg_hba.conf

Locate the following lines:

## IPv4 local connections:
host    all             all             127.0.0.1/32            ident
## IPv6 local connections:
host    all             all::1/128                 ident

Replace ident with md5 so the lines look like this:

## IPv4 local connections:
host    all             all             127.0.0.1/32            md5
## IPv6 local connections:
host    all             all::1/128                 md5

Save and exit the editor by typing :wq.

  1. Start PostgreSQL:

systemctl start postgresql
  1. Verify that PostgreSQL is running:

systemctl status postgresql

You should see Active: active (running) in the output.

  1. Enable PostgreSQL to start on system boot:

systemctl enable postgresql
  1. Switch to the postgres user:

su - postgres
  1. Access the PostgreSQL command-line interface:

psql

You should see the postgres=# prompt.


Next Steps

Once PostgreSQL is installed, you can configure it, create databases and users, and perform other administrative tasks.

Je li Vam ovaj odgovor pomogao? 0 Korisnici koji smatraju članak korisnim (0 Glasovi)

Powered by WHMCompleteSolution