Take the 2-minute tour ×
Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

In order to lower system usage I'm planning to use another server to store my databases. so how can I redirect MySQL queries to another server or make MySQL to store databases on another server?

share|improve this question

closed as not a real question by HopelessN00b, mdpc, Bryan, chutz, growse Dec 22 '12 at 17:40

It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, visit the help center.If this question can be reworded to fit the rules in the help center, please edit the question.

1  
Just tell your application to connect to the remote server. –  Michael Hampton Dec 22 '12 at 19:33

3 Answers 3

up vote 1 down vote accepted

You can use something like mysql proxy link1 link2 for it. But it's not very well supported. Additionally, decrease in performance is somewhat significant. If possible, I would suggest you to simply tell your application to connect to the actual mysql server with a choice. For example, with PHP, there is mysqlnd_ms which allows multiple mysql servers to be added and it load balances among them.

share|improve this answer
    
Thank you, I'll have you advice but what do you think about forwarding all connections on port 3306 to a remote server. is that possible? –  Zim3r Dec 22 '12 at 11:25
    
@Zim3r you can opt to just forward everything through something like haproxy as well. But you should still expect some decrease in performance as you are creating additional task though less than mysql proxy. –  Grumpy Dec 22 '12 at 12:50
    
I don't see a reason here to use something as intelligent as mysqlProxy, looking at the fact, that here we just need to blindly forward all the packets to next server from one IP to another. –  GeekRide Dec 22 '12 at 19:17

Other thing is to use HAProxy in tcp-mode

share|improve this answer

The best way is to forward all the traffic from 3306 port to the 3306 port of destination IP address where you are running mysql.

You can use different packet forwarding applications like iptables, packet filter etc, according to the operating system you are using.

As this works at the packet layer and not really at the application layer, so you will skip the over head of using application to do the redirection. This will be significantly faster than using traditional applications like MysqlProxy.

MysqlProxy is useful when you need the application level understanding, like if you want to redirect mysql write requests to one server and read requests to other servers, but in this scenario, using mysql proxy will be a big extra over head.

share|improve this answer
    
How would port forwarding make it possible to split the traffic? –  Zoredache Dec 23 '12 at 10:50
    
I don't think the question was to split the traffic. The question was to just forward the local Mysql traffic to a remote server. For splitting the traffic, one will have to use MysqlProxy. –  GeekRide Dec 23 '12 at 11:18

Not the answer you're looking for? Browse other questions tagged or ask your own question.