We help IT Professionals succeed at work.

How to redirect Mysql request to another server

Hello,

My progblem is the following:

- I had a MySql account at my web server provider. My Windows based softwares communicated with a MySql table (checked if there was a new version)
-The provider moved my whole account to a new web server. The MySql account and password remained the same but the Ip address changed.
Because of this my softwares coulnd't connect to the database anymore.

I wrote the provider to make a redirection so as when a MySql request comes to the old server it should redirect to the new server, but they said this cannot be done.

Are they true? If not, please write me how it can be done.
They use Linux (I don't know which version) and Apache.

Thank you very much
Comment
Watch Question

Commented:
If you connect to a mysql server from a web app, you usually need (1) a host name or IP address, (2) a port number, (3) a user name, (4) a password, and (5) a database name.

There are exceptions where you will connect through a local pipe to a mysql server which is running on the same machine as the web server, but this is quite uncommon for web hosting.

Having web server and database server on distinct machines is the default situation with most web hosting providers, so your web application really should reflect that.

Your question, if a provider can redirect incoming mysql requests elsewhere: techincally speaking everything is possible having the right tools and enough money.

You should spend your money and efforts in improving your own web app code in favor of portability rather than paying your web hoster to support deprecated connection methods.

HTH, Patric

Distinguished Expert 2019

Commented:
What access to the windows based software do you have in terms of configuration i.e. where the database is.
Does it load data from the registry/configuration file?

get process monitor from www.sysinternals.com
Run it with a filter to only capture details for the MS application that deal with the mysql.

Using this data you can locate what resources it checks i.e. is there a file it accesses? check the file to see whether this is where the mysql data is.
Does it access a registry, check that to see whether that is where the mysql information is being provided.  IF the data is hard coded into the application, and presumably since this is your software, you have the source, you would need to make the changes in the code (preferably adjust the application to rely on this type of information outside the code i.e. config file or registry entry) and recompile the application with the new information in place.
LinuxGuruLinux Server Administrator

Commented:
>>My Windows based softwares communicated with a MySql table

Do you have administrator access to the windows based software? If yes, just login and change the IP address in the MySQL settings for that software. As mentioned by " pwust ", all webapps use database name, database pass, portnumber and hostname/ip. So you can always change these parameters at any time.

Cheers !!!

Author

Commented:
"Do you have administrator access to the windows based software? If yes, just login and change the IP address in the MySQL settings for that software."

My new softwares take the Ip address from database - there is no problem with that.
But in my old softwares the Ip address is hard coded (and I am speaking of Exe files).

Logging to the computers one by one would be very cumbersome since there are more then 100 cheap softwares so the time spent with them would cost me much more than the price of the softwares.
Distinguished Expert 2019

Commented:
Depending on what your setup in the environment is as far as firewall, you could setup a redirect on the firewall i.e. all outgoing requests to IP_of_old_server port 3306 should be redirected to IP_of_new_server port 3306.
This will add overhead to the firewall on the outgoing traffic since each packet will be inspected/compared to the rule. Make sure that your router once a rule is added does not use implied deny.

Are you certain that the IP of the database server is hardcoded into the application?
Or could it be that it is using a hostname i.e. your_database.yourdomain.com such that all it takes is for you to update the yourdomain.com DNS records to reflect that your_database.yourdomain.com is no longer pointing to x.x.x.y but is now at x.y.z.w.
Once the DNS changes propagate, everything will start working again.

These are the cost that you have to consider:
1) whether the cost of replacement of a new software
2) The cost of "going" to one of 50
3) not being able to do any work

which is most cost effective.
For maximum portability, the software should use a hostname instead of an IP address: changing a hostname is a simple function of DNS; an IP address is static.  In the case of using a shared host, the IP address is usually subject to change without any warning.

There's really nothing that can be done for an application that is trying to connect to a SQL server with a specific IP.  That's a hard-coded value that simply cannot be made dynamic.  If it is a malfunctioning hostname, there are "hacks", like creating an entry in the affected system's "hosts" file (%WINDIR%\system32\drivers\etc\hosts).

Author

Commented:
"Depending on what your setup in the environment is as far as firewall, you could setup a redirect on the firewall i.e. all outgoing requests to IP_of_old_server port 3306 should be redirected to IP_of_new_server port 3306."

Can one check on the firewall which database the outgoing request goes to?

I mean there are many databases on the old server - mine is one of them.
Distinguished Expert 2019
Commented:
I think you are misinterpreting my suggestion.  The suggestion is not for what the hosts where the database is hosted should do but what you should do on your LAN to direct the traffic from the application to the database you want.


Your LAN <=> FW <=> Internet
           
Your firewall is where the redirect is to be made.  Alternatively you could setup a proxy and configure it to route the mysql requests.

The straight forward solution is either get a new version or if this is an in house application where source is available, update the information and then deploy the updated version while working on one that is using a configuration file to get this information since the host may at any time change it again.

Author

Commented:
It didn't solve my problem only gave since as I stated in my question there are several hundred *individual* users so it would be a tremendous work to set up the firewalls at so many computers.

It is better for me to create an update software and send the customers to run and change the system.