MySQL – Moving to Another Server Without Updating Connection Strings

MySQL

Currently, I have a Windows 2008 R2 Server which runs both all my websites and all my MySQL databases. I am considering moving MySQL to another seperate server which may also be Windows or may be Linux. My question is, if I do this, and MySQL is then on a different IP address, is there anyway of aliasing the IP address of the new MySQL server from the current server hosting the websites so I do not have to go through and update every single connection string?

Thanks.

Best Answer

I recommend that the database server ip/name is put in some config file and that all connection strings reference this variable. If both machines are on the same network then use some local name (e.g. mysql.network.local). Then if the machine will change again you will just update your hosts file or update dns records.

Both cases require that every connection string will need to be changed - but it seems inevitable.