How to proxy to different named databases on the same server using MySQL Proxy?

Posted by cclark on Server Fault See other posts from Server Fault or by cclark
Published on 2010-03-26T06:37:07Z Indexed on 2010/03/26 6:43 UTC
Read the original article Hit count: 393

Filed under:
|

I would like to have two databases on my MySQL server:

  • DEV_DB_A
  • DEV_DB_B

However, in order to keep everyone's scripts, Query Browser settings and anything else from changing when we switch from using on DB to another I'd like to have everyone connect to DEV_DB and then use something like MySQL Proxy running a lua script which knows the currently active DB is DEV_DB_A and routes queries to there. If we restore a fresh version of the DB to DEV_DB_B or make some changes (e.g. partition a table) we can easily switch to DEV_DB_B by changing one Lua script instead of updating references everywhere.

I had hoped I might be able to symlink inside of the mysql data directory but that didn't work so it seems like MySQL Proxy is a reasonable approach.

Being new to Lua and MySQL Proxy I'm wondering if anyone else has approached the problem this way and how it worked.

© Server Fault or respective owner

Related posts about mysql

Related posts about mysqlproxy