My Drupal installs are set up with apache environment variables/directives (SetEnv DB_NAME somedb) to store the database name, username and password. It appears that Drush isn't able to use these by default as it fails to recognise the apache directives. Is there another way of doing this or can I use some kind of alias or something else to pass the database credentials directly to Drush?


This is not a Drush function; it is a BASH function. For example, you could do this:

DB_NAME=mydbestting drush status

Optionally, you could set your DB_NAME environment variable in your .bashrc file.

However, this is probably not what you want. You would probably prefer to have Drush set the environment variable for you, after you specify the alias. Drush does not have this feature, but there has been some discussion of it in the issue queue on drupal.org:


  • Thanks kindly, that's given me a few ideas to work with. I'll have a look at building a simple bash script to do what I need to. Thanks again! – user1731 Jun 2 '14 at 9:51
  • 1
    You could also just make one bash alias for every site: alias drushforsite1='DB_NAME=site1dbsettings drush and so on. – greg_1_anderson Jun 2 '14 at 16:20

Your Answer

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