Install PostgreSQL with yum, put it in startup and start the database server:
yum install postgresql postgresql-server chkconfig postgresql on service postgresql start
After that, proceed to configuration. Connect to the server:
and create the user pg_usr with password pa$$W0rD:
psql -U postgres -c "CREATE USER pg_usr WITH PASSWORD 'pa$$W0rD' CREATEDB"Now, create the database named pg_db and grant all permissions to the user created above:
psql -U postgres -d template1 -c "CREATE DATABASE pg_db ENCODING='UNICODE';" psql -U postgres -d template1 -c "GRANT ALL PRIVILEGES ON DATABASE pg_db to pg_usr;"To allow trusted connections for all users only from localhost open the config file /var/lib/pgsql/data/pg_hba.conf and add to the end:
local all all trust host all all 127.0.0.1/8 trustNow, you can test the connection:
psql -d pg_db -U pg_usr -W Related Posts: