0

I would like to backup my Postgre db using pg_dump. However, the first question asked by the prompt is the password. But I have no idea what it is. Indeed, it is different from my admin account password, and I don't know where to find it or recover it.

closed as unclear what you're asking by Gaius, Colin 't Hart, Vérace, LowlyDBA, McNets Jan 17 at 15:37

Please clarify your specific problem or add additional details to highlight exactly what you need. As it's currently written, it’s hard to tell exactly what you're asking. See the How to Ask page for help clarifying this question. If this question can be reworded to fit the rules in the help center, please edit the question.

0

pg_dump does not have a password specific to itself. You run pg_dump as a certain database user (often the user spelled 'postgres', but not always), and authenticate however that user would authenticate for any other (non-pg_dump) connection. So your question really has nothing to do with pg_dump.

You probably can't recovery the password (unless you are willing to crack md5 hashes to brute force it--which is really only feasible with poor passwords or with big bucks), but you can use your "admin account" to reset the password to something you do know. How you do that depends on whether "admin account" means a database superuser account, or an OS account for the OS user who owns and runs the database files. Also, it might depend on your settings in pg_hba.conf.

  • It seems that the prompt automatically choose the first DB without allowing to chose the one you want to backup. So I used the following command line instead to chose the right one pg_dump --dbname=postgresql://username:password@127.0.0.1:5432/mydatabase – Maxime Jan 16 at 19:58

Not the answer you're looking for? Browse other questions tagged or ask your own question.