IPAddress server_addr(172,12,137,22);//ip address of the laptop and not the sql server
Connector my_conn;
char user[] = "root";
char password[] = "pass";
void setup() {
Ethernet.begin(mac_addr);
Serial.begin(115200);
while (!Serial);
delay(1000);
Serial.println("Connecting...");
if (my_conn.mysql_connect(server_addr,3306,user,password)){
Serial.println("Success!");
}
else {
Serial.println("Connection failed.");
}
}
void loop()
{
}
we are getting the message
Connecting
and after a long time it shows connection failed.
I've just altered the formatting of your code to make it more readable.
You have got as far as testing your access to the mysql server using the command (or similar) suggested in chapter 'Test Access' of the library reference manual ?:
mysql -ubob -psecret –h192.168.0.2 --port=3306
#include "SPI.h"
#include "Ethernet.h"
#include "mysql.h"
#include "sha1.h"
byte mac_addr[] = { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED };
IPAddress server_addr(172, 12, 137, 22); //ip address of the laptop and not the sql server
Connector my_conn;
char user[] = "root";
char password[] = "pass";
void setup() {
Ethernet.begin(mac_addr);
Serial.begin(115200);
while (!Serial);
delay(1000);
Serial.println("Connecting...");
if (my_conn.mysql_connect(server_addr, 3306, user, password)) {
Serial.println("Success!");
}
else {
Serial.println("Connection failed.");
}
}
void loop()
{
}
hi,
we have tried what you suggested.it is still not working right.
we executed mysql -ubob -psecret -h192.168.0.2 --port=3306 in cmd
it just showed
->
so we are not sure if it worked or not.
we only get the message connecting and after a long pause connection failed is displayed.
once we even gor sql error 1045 as well.
please tell us what else we can possibly do.we are trying to modify firewall settings also although we think that might not be the major problem here.