ChuckBell / MySQL_Connector_Arduino

Database connector library for using MySQL with your Arduino projects.
332 stars 133 forks source link

Can't connect to database #217

Closed Adriel04 closed 6 months ago

Adriel04 commented 6 months ago

I'm trying to connect to a database that i have in AWS (amazon web services) the database is mySQL, and when i try to connect to it via arduino i get this message in the console.

Starting connection to server... ...trying... ...got: 0 retrying... ...trying... ...got: 0 retrying... ...trying... ...got: 0 retrying... Connection failed.

This is the code that i used to connect to the data base

IPAddress server_addr("database endpoint"); // IP of the MySQL server here

char user[] = "admin"; // MySQL user login username char password[] = "pass"; // MySQL user login password char default_db[] = "name";

void setup(){ code for connecting to wifi

if (conn.connect(server_addr, 3306, user, password, default_db)) { delay(1000); // You would add your code here to run a query once on startup. Serial.print("Connected to database"); } else Serial.println("Connection failed."); conn.close(); }