Whenever I run drush sql-dump it will prompt me for the database password. Is there a way that this can be done automatically? I don't quite understand why its not just reading this from settings.php

When I do a drush status --show-passwords it is shown there.

I ask because I want to script db backups to happen via drush. Any advice? Thanks!


I presume you are using postgres.

psql, the commandline tool that Drush uses to manipulate the database, has no provision to pass a password as a commandline option, so Drush cannot provide it even if it knows what it is. You may set up a .pgpass file in your $HOME directory to supply the password; it should contain entries that look like this:


If you create this file, and insure that it is chmod 600, then psql will no longer prompt for the password.

  • Great answer, thanks. Yes, this is a postgres site. I got around the issue by putting trust as an auth method in pg_hba.conf. Thanks for your help. – bobinabottle Jun 27 '12 at 0:18

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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