While configuring a new hosting setup with ROR and PostgreSQL. I faced following issue when application tried to connect postgres database server.
First I set the the password for postgres user in PostgreSQL using following commands.
$ sudo -u postgres psql
Now set the password using following command.
Let’s create a new user account for your application using following command. Also crate a database with ownership of that account.
postgres=# create user "myappusr" with password '_password_'; postgres=# create database "myapp_development" owner "myappusr";
Now edit pg_hba postgresql configuration file and update configuration. By default PostgreSQL uses IDENT-based authentication. You need to allow username and password based authentication. IDENT will never allow you to login via -U and -W options.
# vim /var/lib/pgsql/9.4/data/pg_hba.conf
local all postgres trust local all myapp_usr trust # IPv4 local connections: host all all 127.0.0.1/32 trust # IPv6 local connections: #host all all ::1/128 trust