I want to transfer the data from the database to Arduino. For this, I am using MYSQL_Connector library in Arduino. But I'm getting error like this: "Connection Failed". I cannot connect to database. Also, I'm using XAMPP server.
I checked MYSQL server's IP address, port and username-password.
#include <SPI.h>
#include <Ethernet.h>
#include <MySQL_Connection.h>
#include <MySQL_Cursor.h>
byte mac_addr[] = { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED };
IPAddress server_addr(x,x,x,x); // the IP address to that of the system on which my MySQL server is set up
char user[] = "user"; // MySQL user login username
char password[] = "1234"; // MySQL user login password
// Sample query
char query[] = "SELECT id FROM world.city";
EthernetClient client;
MySQL_Connection conn((Client *)&client);
void setup() {
Serial.begin(9600);
while (!Serial); // wait for serial port to connect
Ethernet.begin(mac_addr);
Serial.println("Connecting...");
if (conn.connect(server_addr, 8080, user, password)) {
delay(1000);
}
else
Serial.println("Connection failed.");
}