Check out example codes for "psql: FATAL: Ident authentication failed for user "postgres"". It will help you in understanding the concepts better.

Code Example 1

$ sudo -u postgres psql
\password
Enter password: ...
...

Learn ReactJs, React Native from akashmittal.com