I've just updated a site from EE2.9.3 to 5.1.1 and am attempting to deploy to a staging location so my client can preview it.
I've added a switch statement to users/config/config.php in order to keep things working locally and on staging. Locally all works as expected. However on staging I get an error about database connections:
SQLSTATE[HY000] [1045] Access denied for user 'root'@'localhost' (using password: YES)
ee/legacy/database/drivers/mysqli/mysqli_connection.php:81
Here is my switch statement with real paths and user/password replaced
switch (strtolower($_SERVER['HTTP_HOST'])) {
// Live
case 'livedomain.com' :
// Live stuff here
break;
// staging
case 'staging.com' :
// Staging stuff here
// local stuff here
$config['cp_url'] = 'http://staging.com/admin.php';
$config['database'] = array (
'expressionengine' =>
array (
'hostname' => 'localhost',
'password' => 'password123',
//'user' => 'user123',
'database' => 'dennis',
),
);
$config['site_url'] = 'http://staging.com/';
$config['base_url'] = 'http://staging.com/';
$config['base_path'] = 'path/to/public';
$config['theme_folder_path'] = 'path/to/public/themes/';
$config['theme_folder_url'] = 'http://staging.com/themes/';
$config['new_version_check'] = 'n';
break;
// main local site
case 'dennis.test' :
// local stuff here
$config['cp_url'] = 'http://dennis.test/admin.php';
$config['database'] = array (
'expressionengine' =>
array (
'hostname' => 'localhost',
'password' => 'root',
'database' => 'dennis',
),
);
$config['site_url'] = 'http://dennis.test/';
$config['base_url'] = 'http://dennis.test/';
$config['base_path'] = 'D:\sites\dennis-drenner';
$config['theme_folder_path'] = 'D:\sites\dennis-drenner/themes/';
$config['theme_folder_url'] = 'http://dennis.test/themes/';
$config['new_version_check'] = 'y';
break;
}
I tried adding this 'user' => 'user123',
on staging but that didn't help. I"m not sure where to set the database user - it's not in local but connects correctly and I need to override that so it works on staging.
Please advise.