phpmysqldrupal-7migrate

Connect to an external Database (other Host) on Drupal 7


I want to connect to an external Database on another Host (not localhost) on Drupal because i want to migrate Content with the Migrate Module.

thats in my settings.php

$databases['for_migration']['default'] = array(
  'driver' => 'mysql',
  'database' => 'dbname',
  'username' => 'username',
  'password' => 'password',
  'host' => 'other-host.com',
  'prefix' => '',
  'port' => '',
);

And in another method im calling the database via:

$query = Database::getConnection('default', 'for_migration')

thats the error which appears:

PDOException: SQLSTATE[HY000] [2003] Can't connect to MySQL server on 'host.com' (13) in    MigrateMigration->__construct() (Zeile 16 von /var/www/html/x/sites/all/modules/migrate_x/x.inc).

So if i call a database on localhost, there are no errors and all migrates perfectly. But i cant connect to a database on an external host.


Solution

  • It was my fault. I have set httpd_can_network_connect on the remote server to on.

    But the solution was to set it on my local machine. After that i can connect to an external Host. So it was a SELinux Problem.

    Thanks to @fobia