Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

pg_dump fails with error: `FATAL: role "username" does not exist`

Tags:

postgresql

I have a db named backupdb, I want to import this to my local rails app so I want to take a dump of it.

When I am running pg_dump backupdb, I am getting below error.

pg_dump: [archiver (db)] connection to database "backupdb" failed: FATAL: role "username" does not exist

what's wrong here. Please help.

I downloaded the db from my email and then trying to create a dump so I can import it to my local rails app

like image 834
Suraj Avatar asked Jun 07 '16 06:06

Suraj


2 Answers

Try this way, it works!!

$ pg_dump -h localhost -U postgres -Fc mydb > db.dump
like image 120
VijayGupta Avatar answered Sep 21 '22 07:09

VijayGupta


This command will take the backup of complete database

pg_dump -h localhost -U "dbuser" "dbname" -Fc > "pathfilename.backup"

**ex:** pg_dump -h localhost -U mani manidb - Fc > "thamesdb.backup"

for more pg_dump formats please refer to this answer

like image 22
Mani Deep Avatar answered Sep 21 '22 07:09

Mani Deep