Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

PostgreSQL: pg_dump: [archiver (db)] connection to database "dbase" failed: FATAL: Peer authentication failed for user "postgres"

Tags:

postgresql

Solved: I added .pgpass in the home.

I have the line:

host    all             all             127.0.0.1/32            md5

in /etc/postgresql/9.4/main/pg_hba.conf but when I run:

pg_dump -U postgres dbase -f dbase.sql

I get:

pg_dump: [archiver (db)] connection to database "dbase" failed:
FATAL: Peer authentication failed for user "postgres"

like image 774
basante Avatar asked Feb 10 '16 12:02

basante


2 Answers

The Problem you have is, that if u dont define the Host, your system will decide.

explicit add "-h localhost", this will fix it

like image 69
Bobo Avatar answered Sep 20 '22 07:09

Bobo


If adding -h localhost doesn’t work you can try adding -h 127.0.0.1

pg_dump -h 127.0.0.1 -U <username> -d <database_name> -W > bk_name.sql
like image 37
Diego Tejada Avatar answered Sep 17 '22 07:09

Diego Tejada