0

I want to redirect MySQL queries destinated to a server (ex:192.168.1.1) to another server (ex:192.168.1.2)

I use MySQL proxy V0.8.5 on the first server (192.168.1.1) and tried the following command

mysql-proxy --proxy-address=192.168.1.1:3306 --proxy-backend-addresses=192.168.1.2:3306

But it give me those errors

2015-09-11 14:34:32: (critical) plugin proxy 0.8.5 started
2015-09-11 14:34:32: (critical) ..\..\mysql-proxy-0.8.5\src\network-socket.c:492
: bind(192.168.1.3:3306) failed: No error (0)
2015-09-11 14:34:32: (critical) ..\..\mysql-proxy-0.8.5\src\chassis-mainloop.c:2
70: applying config of plugin proxy failed
2015-09-11 14:34:32: (critical) ..\..\mysql-proxy-0.8.5\src\mysql-proxy-cli.c:59
9: Failure from chassis_mainloop. Shutting down.

But I can not figure out why this does not work. I am open to any other way to redirect queries from on server to another.

More informations

The queries are made by users, those users are in the same network of the first server (192.168.1.1). This server will not run MySQL but will redirect all the queries to another server (192.168.1.2). This other server is in another network but is visible by the server 192.168.1.1 with a VPN access.

I do not know if that can be useful but I prefear to mention it.

I am open to any other way to redirect queries from one server to another

Atnaize
  • 1,766
  • 5
  • 25
  • 54
  • Once I did that without proxy, and that was adding a new user that can access through a host other than localhost, say this "192.168.1.2" and then while connecting from the other host I mentioned it in the connection string like "mysql -u root -h 192.168.1.2 -p", I did not have problems in that project. – Musa Haidari Sep 16 '15 at 12:39

2 Answers2

2

A mysql proxy seems to be superfluous for the need you describe. A simple port forwarding may suffice. The easiest route I can think of is a SSH port forwarding:

user@front-server$ ssh -L 3306:private-server:3306 user@private-server

Anyone who can reach front-server can now connect to its port 3306, which is seamlessly forwarded to private-server.

RandomSeed
  • 29,301
  • 6
  • 52
  • 87
  • I know it is a little "Overkill" but I really want to know why this is not working. I already have forwarded the port 3306 for MySQL with a simple route under Windows. – Atnaize Sep 17 '15 at 11:33
  • MySQL proxy is officially Alpha, I wouldn't rely on it too much. Anyways, there seems to be a network issue, perhaps MySQL Proxy is unable to bind to port 3306 because it is already in use by this very tunnel you have set. – RandomSeed Sep 17 '15 at 11:55
0

You can use the HAPROXY solution is solid rock on mysql and it looks like it will fir perfectly for your needs.

andres
  • 143
  • 4