This article describes how to create a PostgreSQL installation that you can use for local testing.
To install PostgreSQL on your virtual machine, follow these steps:
yum install postgresql-server postgresql-contrib
After installation completes, type the following command to initialize PostgreSQL:
postgresql-setup initdb
To enable password authentication, type the following command:
vi /var/lib/pgsql/data/pg_hba.conf
In the pg_hba.conf file, 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 as follows:
# IPv4 local connections: host all all 127.0.0.1/32 md5 # IPv6 local connections: host all all ::1/128 md5
Type the following command to start PostgreSQL:
systemctl start postgresql
To confirm PostgreSQL is running, type the following command:
systemctl status postgresql
You should see Active: active (running) in the output.
To make PostgreSQL start automatically on system boot, type the following command:
systemctl enable postgresql
To confirm that the postgres user is active, type the following command:
su - postgres
As the postgres user, type the following command:
psql
You should see the postgres=# prompt.
Subscribe to receive weekly cutting edge tips, strategies, and news you need to grow your web business.
No charge. Unsubscribe anytime.
Did you find this article helpful? Then you'll love our support. Experience the A2 Hosting difference today and get a pre-secured, pre-optimized website. Check out our web hosting plans today.
We use cookies to personalize the website for you and to analyze the use of our website. You consent to this by clicking on "I consent" or by continuing your use of this website. Further information about cookies can be found in our Privacy Policy.