4

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!

1 Answer 1

9

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:

localhost:5432:*:www-data:PASSWORD

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

1
  • 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. Jun 27, 2012 at 0:18

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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