简体   繁体   中英

Unable to connect through mysql on other server

I have two Linode server, On one server we have drupal file structure and on other server we have database.

I want to connect through the database but can't.

In my hosts file mysql xxx.xxx.xxx.xxx(my db server ip)

Setting.php

$databases = array (
  'default' => 
  array (
    'default' => 
    array (
      'database' => '*****',
      'username' => '*****',
      'password' => '*****',
      'host' => 'mysql',
      'port' => '',
      'driver' => 'mysql',
      'prefix' => '',
    ),
  ),
);

and in my.conf file bind-address = xxx.xxx.xxx.xxx(db server address)

after this change in my.conf, I am not able to start mysql on this server.

What am I doing wrong or forgot to configure?

While this is not the most secure way to do it, this will get it working: On your DB server, make sure your bind-address set for MySQL is set to 0.0.0.0. This will make it run on all IPs, and not be bound to localhost, accessible only from itself (127.0.0.1).

The server with Drupal does not need MySQL installed. In your Drupal settings (haven't configured specific database addresses before in Drupal, so I don't know the option off my mind), change the address for your database to the IP address of your MySQL server. I'm assuming it would have previously been set to 127.0.0.1, aka localhost. After setting this, it should work fine. Be sure to use the private IP address of your DB server.

Ideally, you would want to configure your database to allow specific access to your Drupal server's IP address, since setting it to 0.0.0.0 could leave it more open than desired (though still password protected, assuming you did such during setup).

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM