Rails postgres error authentication failed
FATAL: password authentication failed for user “postgres” while rake db:create
So we are resetting the password for postgres user
Go to your Postgresql Config and Edit pg_hba.conf
$ sudo vim /etc/postgresql/9.3/main/pg_hba.conf
Then Change this Line :
Database administrative login by Unix domain socket
local all postgres md5
to :
Database administrative login by Unix domain socket
local all postgres peer
then Restart the PostgreSQL service via SUDO command
$ sudo service postgresql restart
then
$ psql -U postgres
You will be now entered and will See the Postgresql terminal
then enter
postgres=#\password
and enter the NEW Password for Postgres default user, After Successfully changing the Password again go to the
pg_hba.conf and revert the change to “md5”
now you will be logged in as
$ psql -U postgres
with your new Password.
Peer Authentication
The peer authentication method works by obtaining the client’s operating system user name from the kernel and using it as the allowed database user name (with optional user name mapping). This method is only supported on local connections.
Password Authentication MD5
The password-based authentication methods are md5 and password. These methods operate similarly except for the way that the password is sent across the connection, namely MD5-hashed and clear-text respectively.
If you are at all concerned about password “sniffing” attacks then md5 is preferred.
reference : https://stackoverflow.com/questions/12720967/how-to-change-postgresql-user-password