how to handle fatal: password authentication failed for user “postgres” while rake db:create

This article is gives basic knowledge about how handle FATAL: password authentication failed for user “postgres” while rake db:create in ruby on rails. You might forgot to create postgres user while installing postgres database libraries.

Follow these steps. Run these commands in console

ubuntu_root_name-21:38:15:~/workspace/project_name (master)$ sudo su

The above command gets you the command line interface in full admin mode.

Path will be changed as below

[root@webnish:/home/Desktop/workspace/tappnsee#

run this command now
root@webnish:/home/Desktop/workspace/tappnsee# su - postgres
The above command gets you the psql command line interface in full admin mode.
Path will be changed as below

postgres@webnish:~$

run this command now
postgres@webnish:~$ psql
The above command logins to postgres database.
Path will be changed as below

psql (9.5.19)

Type "help" for help.

postgres=#

run this command according to requirement.
If USER is not present. You can run this command to create USER
CREATE USER 'USER' PASSWORD 'PASSWORD';
If you want to alter the password for USER. You can run this command for updating password
postgres=# ALTER USER user_name WITH PASSWORD 'new_password';
If you want to drop user. You can run this command to drop USER
postgres=# DROP USER 'USER';