Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Peer authentication failed for user "postgres"

I have been using postgreSQL, trying to dump plain backup file using command:

psql -U postgres DATABASE < path to file.backup

But getting peer authentication failure. Even tried changing pg_hba.conf from peer to md5, but didn't work.

like image 342
Yogesh Singh Avatar asked Dec 01 '25 05:12

Yogesh Singh


1 Answers

peer means you are not OS user postgres, while trying to connect as one,

  1. sudo su - postgres
  2. and then psql DBNAME >file.sql

https://www.postgresql.org/docs/current/static/auth-methods.html#AUTH-PEER

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.

like image 106
Vao Tsun Avatar answered Dec 03 '25 23:12

Vao Tsun



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!