is it possible to redirect entire mysql query to another server?
I've have many apps in differents server that comunicate with a single database (windows machine).
For transfer database (to a linux server) without change any IP inside many many php files (there are a lot of things that i don't know because is not my creation but is my legacy) there's something i can do? Proxy?port forwarding?
Afaik, mysql implementations don't offer this functionality, however, you can "proxy" connections using an ssh tunnel like this:
ssh -N [email protected] -L 3306:127.0.0.1:3306
This requires an ssh-server on the host that serves the mysql (on port 3306) and you having ssh-access to that machine. You run the command on the machine your php is excecuted from, then you can, as long as it runs, access the mysql host on "localhost". All requests will be securely tunneled to the remote mysql server.
The -L switch instructs ssh to forward tcp connections on local port 3306 to port 3306 on the machine you ssh to.
The -N switch instructs ssh to do just that and not run a command.
If you add the -f switch, the command will immidiately fork into background, which may be useful for this usecase.
You probably also want to use passwordless ssh
However, this is probably not a clean solution for production. I use this method only for development purposes and I'd suggest you fix your codebase on the long run (i.e. put your mysql configuration in a central place).