Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have an Azure virtual machine holding an Ubuntu system, with MySQL server and I want to access the database from a web application. When I installed mysql-server, I executed

$ iptables -I INPUT -p tcp --dport 3306 -m state --state NEW,ESTABLISHED -j ACCEPT
$ iptables -I OUTPUT -p tcp --sport 3306 -m state --state ESTABLISHED -j ACCEPT

to allow tcp connections. In the file /etc/mysql/my.cnf I added bind-address =, which is the "Virtual IP Address" that Azure panel tells me.

In mysql, the user I am using to connect has all privileges on the database needed (I think):

mysql> SHOW GRANTS FOR 'user'@'%';
| Grants for user@%                                                                                            |
| GRANT ALL PRIVILEGES ON `database`.* TO 'user'@'%'                                                          |

But when the application tries to connect to the database, I recieve the error:

 CDbConnection failed to open the DB connection: SQLSTATE[HY000] [2003] Can't connect to MySQL server on '' (4) 

(It's a Yii framework application, in case it matters).

I have full SSH access to the virtual machine, using the given IP address and a specific port. Azure also tells me the "Internal IP address", which is I have tried binding the MySQL server to that address and to, but none has worked.

I suspect the problem is the redirection made to access my specific instance in the server, but I don't know how to solve it.

share|improve this question
up vote 5 down vote accepted

I finally solved it. The problem was that I didn't have an endpoint in Azure.

I have created the endpoint with the 3306 port and restarted mysql-server with sudo restart mysql

Other mistake I had is that I needed to set the bind address as the Internal IP Address of the server.

share|improve this answer
Other mistake I had is that I needed to set the bind address as the Internal IP Address of the server. how do I bind on a Windows Box? – Bart Calixto Dec 31 '13 at 14:32
In my case, binding to the internal IP address worked. – Justin Skiles Jan 26 '15 at 2:23

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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