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.