I have the following params in settings.php to connect to an external database .
$databases['d8243']['default'] = array (
'database' => 'drupal8',
'username' => 'root',
'password' => '123123',
'prefix' => '',
'host' => '192.168.1.243',
'port' => '3306',
'namespace' => 'Drupal\\Core\\Database\\Driver\\mysql',
'driver' => 'mysql',
);
And am using the following code to access some data from the db .
\Drupal\Core\Database\Database::setActiveConnection('d8243');
$query = "Select * from node__field_target_config_controller";
$result = db_query($query);
$obj = $result->fetchObject();
echo json_encode($obj);
exit;
My current server and the external db server are in a same network
.
But am geting the following error :
exception 'PDOException' with message 'SQLSTATE[28000] [1045] Access denied for user 'root'@'192.168.1.245' [error] (using password: YES)' in /var/www-drupal/core/lib/Drupal/Core/Database/Driver/mysql/Connection.php:149
Is there a different method to connect to remote db in D8 ? or how to do it ?
When i checked d6/d7 versions have an option to specify remote db like
$db_url = 'mysql://username:[email protected]/databasename';
how to do this in D8 ?