HAproxy mysql - what is username and password for php app

May 20, 2015 681 views
Server Optimization


I followed the tutorials here:

and successfully create HAproxy for a Master-Master Mysql

However, I am not able to find any correct way to connect a php app to the database through HAProxy

I tried netstat -tlpn | grep 3306 and got the following result:

tcp        0      0*               LISTEN      946/haproxy

however, when trying mysql -h <IP of HAProxy Droplet> -u root -p
I could not connect because of incorrect password. My passwords are exactly as the ones in the tutorials and I have tried all of them but it doesn't work.

Any help is really appreciated. Thank you in advanced

1 Answer

If you followed that tutorial, there are a few things to note:

  • The MySQL user set up is named haproxy_root not root as used in this question. So the password for the root user is the one from when you initially installed MySQL, not the user set up in the article.
  • It is only accessible via localhost on the HAproxy instance.

If you need to connect to the database from another host, you'll need to change the bind address in your HAProxy configuration. To bind to all network interfaces, it should look like:

listen mysql-cluster
    bind :3306
by Jesin A
HAProxy is an open source software which can load balance HTTP and TCP servers. In the previous article on HAProxy we configured load balancing for HTTP and in this one we'll do the same for MySQL. All your MySQL servers have to be configured to perform Master-Master replication as load balancing involves both reading and writing to all the backends.
Have another answer? Share your knowledge.