MySQL -- enable connection to remote server via local /tmp/mysql.sock

Posted by Kevin on Server Fault See other posts from Server Fault or by Kevin
Published on 2011-03-12T03:44:29Z Indexed on 2011/03/12 8:11 UTC
Read the original article Hit count: 454

Filed under:
|

Hey all,

I run a shared hosting provider and we're looking to move to a High Availability (replicated across multiple datacenters) setup for our hosting. We have created a replicated MySQL setup with failover that works wonderfully, and we'd like to move all of our clients' databases to it.

The only trouble is that we have many many customers, all of whom have configured their Wordpress, Drupal, etc. installations to connect to MySQL via a local socket, not to the address of the remove server.

I would hate to have to go through manually and change the connection statement in all of our clients' sites.

What I'd ideally love to see is a program that listens on /tmp/mysql.sock and forwards connections there to the remote server I specify. I've seen SQL Relay, but it seems to require that I hardcode all of the database names and usernames and passwords into its configuration file. This is not going to work for me because our users add new databases dynamically all of the time, and I'd rather not have to write code to updated SQLRelay's config file every time.

Does anyone have an idea on how to do this?

Alternatively, I'd accept idea on how to handle this at the PHP level. (i.e. redirect any attempted calls to mysql_connect() to use that hostname rather than localhost)

Thanks, Kevin

© Server Fault or respective owner

Related posts about mysql

Related posts about php