1

I made a copy of one of my drupal sites and I'm attempting to set it up to use a different database but for some reason it's ignoring changes to my settings.php file. My settings.php file is in sites/default/settings.php and contains the following

$databases['default']['default'] = array (
        'database' => 'my_db_database',
        'username' => 'my_db_user',
        'password' => 'my_db_password',
        'host' => 'my_db_host',
        'port' => '3306',
        'driver' => 'mysql',
        'prefix' => '',
        'collation' => 'utf8mb4_general_ci',
);

However the changes I made to it don't seem to take. It's still using the old database. As a test I even put in incorrect information and tried commenting everything out to see if I can break it, but there was no effect. I also checked to make sure there was no local.settings.php file.

Is there something that needs to be done to reload the settings.php file. If not is there a way to see what settings.php file is being used in case there's another file overriding it?

UPDATE: Turns out the issue was a dummy mistake on my part. The domain was pointing to the wrong server. However I'm not closing this question because I believe these answers could be helpful to others in similar situations.

  • Can you share the rest of your settings.php file? Are there any includes in it? – Chance G Feb 1 '18 at 22:10
  • 1
    Maybe related to (compiled) PHP code caching. Modern PHP versions come with Opcache. If your webserver is using PHP in FastCGI or PHP-FPM mode, you may have to restart the PHP services and/or your webserver for code changes to take effect. Also flushing your Drupal caches might be of help. – Mario Steinitz Feb 2 '18 at 0:09
1

Check with including namespace. Also, check if any other code override configuration or do you enabled settings.local.php. Add this code to the bottom of settings.php

 $databases['default']['default'] = array (
  'database' => 'my_db_database',
  'username' => 'my_db_user',
  'password' => 'my_db_password',
  'prefix' => '',
  'host' => 'localhost',
  'port' => '3306',
  'namespace' => 'Drupal\\Core\\Database\\Driver\\mysql',
  'driver' => 'mysql',
);
1

The settings.php file is usually 444 as permission, check if the "last modified" is as you aspect, otherwise you need to change the permissions temporaly to 777 in order to overwrite it

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.