Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

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 = 168.63.178.87, 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 *.* TO 'user'@'%' IDENTIFIED BY PASSWORD 'pass_ommited' |
| 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 '168.63.178.87' (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 10.78.28.85. I have tried binding the MySQL server to that address and to 0.0.0.0, 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
add comment

1 Answer 1

up vote 3 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 Dec 31 '13 at 14:32
add comment

Your Answer

 
discard

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.