Postgres, is a relational database management system that provides an
implementation of the SQL querying language. It is a popular choice for many
small and large projects and has the advantage of being standards-compliant and
having many advanced features like reliable transactions and concurrency
without read locks.
In This post we will discuss how to
install and configure PostgreSQL on CentOS 7.
1) CentOS's default repositories
contain Postgres packages, so we can install them without a hassle using
the yum package system.
yum install postgres* -y
2) Once the PostgreSQL software is
installed, we have to perform a few steps before we can use it.
postgresql-setup initdb
3) Start
and enable postgresql service
sudo systemctl start postgresql
sudo systemctl enable postgresql
4) PostgreSQL installation will create a new
user called postgres in VM which can auto login to psql.
By
default, PostgreSQL does not allow password authentication.
To disable this first we need set a password for postgres user by
following below steps.
su postgres
psql # you will be
login to postgresql client interface
\password # it will
prompt for password for postgresql
\q # it
will quit from psql
Then we need to edit its host-based
authentication (HBA) configuration.
vi /var/lib/pgsql/data/pg_hba.conf
Before Configuration change
# "local" is for Unix
domain socket connections only
local all all peer
# IPv4 local connections:
host all all 127.0.0.1/32 ident
# IPv6 local connections:
host all all ::1/128 ident
After configuration changes
# "local" is for Unix
domain socket connections only
local all all md5
# IPv4 local connections:
host all all 127.0.0.1/32 md5
# IPv6 local connections:
host all all ::1/128 md5
5) Restart the postgresql service to reflect config changes.
sudo systemctl restart postgresql
6) Now please try to connect to
postgresql with provided creds earlier and start creating your databases and
schemas as per your application requirements.
No comments:
Post a Comment