I'm installing a drupal site on a cloud, which has a remote database cloud service.
But I found that drupal seems ignore the host
I give and use unix_socket
to connect the remote database.
Here is the Set up database screen during installation. I'm sure database name, username and password are correct. I have try ip address and domain name in the host
field. The socket
field leaves empty.
And I got:
Failed to connect to your database server. The server reports the following message: SQLSTATE[HY000] [2002] Invalid argument.
I'm not familiar with PHP and mysql, I don't know a better way to find out what Invalid argument is. I So I do some grep
and add some print_r()
in [drupaldir]/includes/database/database.inc
:
$driver_options[PDO::ATTR_ERRMODE] = PDO::ERRMODE_EXCEPTION;
print_r($dsn);print_r($username);print_r($password);print_r($driver_options);
// Call PDO::__construct and PDO::setAttribute.
parent::__construct($dsn, $username, $password, $driver_options);
This is what I got (add a few line break, and replace the real name and password):
mysql:unix_socket=;dbname=demo_db
demo_username
demo_password
Array ( [1000] => 1 [20] => 1 [3] => 2 )
Is this mean, Drupal installation ignores the host
what ever I give and just use unix_socket
even it's empty?
unix_socket=;
is an empty string and not used in that output. Make sure your remote firewall accepts connections on the mysql port from your host/ip address.