psql: FATAL: Peer authentication failed for user “youruser”

Now i will explain ho to connect or login to PostgreSQL database using Command Line on Linux OS. But sometimes we get an error such us my title post. Example i want to login to the PostgreSQL with user “imron” and database name “spp”:

aim@aim-tian:~$ sudo psql -U imron spp
psql: FATAL: Peer authentication failed for user “imron”

And then to fix it, then we must determine a more specific host. For example, I installed postgresql on a personal computer with localhost address or using ip 127.0.0.1. Then use the following command:

aim@aim-tian:~$ sudo psql -h localhost -U imron spp
Password for user imron:
psql (9.1.9)
SSL connection (cipher: DHE-RSA-AES256-SHA, bits: 256)
Type “help” for help.

spp=>


Or use this command:

aim@aim-tian:~$ sudo psql -h 127.0.0.1 -U imron spp
Password for user imron:
psql (9.1.9)
SSL connection (cipher: DHE-RSA-AES256-SHA, bits: 256)
Type “help” for help.

spp=>

So this is very simple, and very easy.. 😛

One comment

  1. Have you ever thought about including a little bit more than just your articles?

    I mean, what you say is valuable and all. Nevertheless think about
    if you added some great pictures or videos to give your posts more, “pop”!
    Your content is excellent but with pics and clips, this blog could certainly be one
    of the best in its niche. Awesome blog!

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s