For some specific automation reasons, I use the following snippet in settings.php rather than defining db credentials directly in it.
$databases = array(
'default' => array(
'default' => array(
'database' => $_SERVER['DB_NAME'],
'username' => ini_get('mysql.default_user'),
'password' => ini_get('mysql.default_password'),
'host' => 'localhost',
'port' => '',
'driver' => 'mysql',
'prefix' => '',
),
),
);
And when I try to use drush, it won't pick up database credentials. How can I give the right database credentials to Drush? Can I define something in drushrc files per project?
The following is what I get from drush status
.
Drupal version : 7.22
Site URI :http://default
Database driver : mysql
Database hostname : localhost
Database username :
Database name:
Default theme : garland
Administration theme : garland
PHP configuration : /etc/php5/cli/php.ini
Drush version : 5.4
Drush configuration :
Drupal root : /home/oep/www/dev/docroot Site path : sites/default
File directory path : sites/default/files
php.ini
in the first place.require ../database.inc
(put above Drupal's directory), it would be much easier. But there is hardly a way to tell CLI about Apache's config. Certainly not the one I'd dare to use and believe it stable in automated environment.