11 years, 1 month ago.  This question has been closed. Reason: resolved the issue

Connecting mbed to MySQL data base

Hi All,

I’m a newbie to the mbed network and I’m currently trying to connect my mbed board to a MySQL data base using the MySQLClientExample that is in the cookbook. My goal is to upload data from several different sensors but right now I can’t even manage to get the MySQLClientExample working. I’m getting the error “Error 5 during connection” Is there anyone that could help me out? I have tried numerous different sequences for the connection. It’s a remote host server that the MySQL data base is on. Here is the code that I’m trying to use.

Kind regards, Jason

#define SQL_SERVER   "78.xxx.xxx.92"
#define SQL_USER     "project"
#define SQL_PASSWORD "atxxxxxx08"
#define SQL_DB       "Test"

EthernetNetIf eth; 
MySQLClient sql;

MySQLResult sqlLastResult;
void onMySQLResult(MySQLResult r)
{
  sqlLastResult = r;
}

int main()
{
  printf("Start\n");

  printf("Setting up...\n");
  EthernetErr ethErr = eth.setup();
  if(ethErr)
  {
    printf("Error %d in setup.\n", ethErr);
    return -1;
  }
  printf("Setup OK\n");

  
  Host host(IpAddr(), 3306, SQL_SERVER);
  
  //Connect
  sqlLastResult = sql.open(host, SQL_USER, SQL_PASSWORD, SQL_DB, onMySQLResult);

etc............................

When using a computer on the same network as the mbed are you able to connect to the MySQL server?

posted by Stephen Paulger 29 Mar 2013

Hi Stephen,

The simple answer there is no! however I am able to upload the sensor data to the cosm website tobe graphed. Any ideas?

posted by Jason Cornally 29 Mar 2013

1 Answer

11 years ago.

Update: The MySQL code was correct, the issue was with the remote server. Remote device access needed to be enable on the server. Be sure to create the table after you enable remote device access, as I found out the hard way.

Accepted Answer