Connecting to MySQL Microsoft Azure Database with NodeMCU (ESP8266) module

I want to connect my NodeMCU to my MySQL Microsoft Azure database. This is the code that I'm running in the Arduino IDE, and it succesfully uploads and connects to my WiFi, but it gets stuck when trying to establish a connection to the MySQL Database. The code can be seen in the attached file.

However, when I run the code I get the following output:

Connected to dankweb
IP address: 192.168.43.136
DB - Connecting...
.............

As you can see it simply prints dots because it can't get through the while loop. In my google search it seems that a lot of people have this issue. Please help me!

MySQLArduinoCode.ino (1.37 KB)

but it gets stuck when trying to establish a connection to the MySQL Database.

No. It gets stuck trying to connect to the server where the database is running. It doesn't attempt to connect to the database until after it connects to the server.

Is your server accepting connections on port 3306? Is your server address correct?

Sorry, yes. That is what I meant.

Yes, the server is accepting connections on port 3306, I have an application on my phone able to retrieve/connect to the server & database (written in Java). I have also verified this with Nmap and connected to it through MySQL WorkBench, this problem is only with the NodeMCU :frowning: