简体   繁体   中英

Remote mySQL, can connect from remote SSH, but remote php/httpd fails to connect

I have a new drupal site running behind a load balancer. I've got one master slave set up with the database and another that syncs files from the web dir.

For the remote slave, I've got ENV vars setup for the database host, which is the INTERNAL IP of the master slave holding the database. This works fine as the master has this too with it's ENV var being 'localhost'

Now, when accessing the site, getting put on the master slave works fine. But when hitting the remote slave I get the database error from Drupal :

PDOException: SQLSTATE[HY000] [2002] Can't connect to local MySQL
server through socket '/var/lib/mysql/mysql.sock' (2) in 
lock_may_be_available() (line 167 of /var/www/html/includes/lock.inc).

I've run the regular GRANT commands for the remote slave and I can connect over SSH from the slave machine using

mysql -u root -p -h master.slave.internal.ip

So from what I can tell it's not a firewall or mysql permissions issue, I'm stumped! :(

Big beer coming someones way, as I'm left scratching my head.

It looks like your Drupal config is wrong if you need to connect to a database on a different server. The error message says it can't connect to the "local MySQL server", not that it can't connect to "MySQL on server ". Look at settings.php and make sure the database ip address/hostname is correct.

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