Hello everyone! Recently, I've been trying to send data to MySQL using ESP32, but encountered an issue that I can't resolve (as shown in the attached image).

I'm using the Arduino IDE for coding. After completing the WiFi connection, attempting to connect to MySQL gets stuck. I've checked that the WiFi and MySQL credentials are correct (they're on the same local network), and the port is also open without any blocking. Strangely, MySQL shows attempted logins but they fail. It's somewhat like a connection timeout issue. I'd like to ask all the experts here if you know where the problem might be, or if anyone has encountered a similar situation before! ![]()
Below is the MySQL connection code.
#include <WiFi.h>
#include <MySQL_Connection.h>
#include <MySQL_Cursor.h>
const char* ssid = ""; //WIFI 名稱
const char* WIFI_password = ""; //WIFI 密碼
IPAddress server_addr( , , , ); // MySQL IP地址
unsigned int server_port = 3306; // MySQLport
char user[] = ""; // MySQL帳號
char password[] = ""; // MySQL密碼
char db[] = ""; // 數據庫
WiFiClient client;
MySQL_Connection conn((Client *)&client);
void setup() {
Serial.begin(115200);
delay(100);
Serial.println();
Serial.print("Connecting to ");
Serial.println(ssid);
WiFi.begin(ssid, WIFI_password);
while (WiFi.status() != WL_CONNECTED) {
delay(500);
Serial.print(".");
}
Serial.println("");
Serial.println("WiFi connected");
Serial.println("Connecting to database...");
if (conn.connect(server_addr, server_port, user, password, db)) {
Serial.println("Connected to database");
MySQL_Cursor *cur_mem = new MySQL_Cursor(&conn);
char query[] = "SELECT * FROM your_table";
cur_mem->execute(query);
delete cur_mem;
} else {
Serial.println("Connection failed");
Serial.println("Exiting program");
while (true) {
delay(1);
}
}
}
void loop() {
delay(1000);
}
