Community
cancel
Showing results for 
Search instead for 
Did you mean: 
idata
Community Manager
1,159 Views

MySql Connector/arduino 1.1 on Galileo HELP!!

Hi, i'm trying to run the basic example of the library but the Sketch stops in the line "if (conn.connect(server_addr, 3306, user, password))" .

 

I don't know what could be the problem.

 

this is the code

 

# include

 

# include

 

# include

IPAddress server_addr(192,168,1,100); // IP of the MySQL *server* here

 

char user[] = "cymo"; // MySQL user login username

 

char password[] = "cymo"; // MySQL user login password

 

// Sample query

 

char query[] = "SELECT * FROM cymo_db.login";

 

EthernetClient client;

 

MySQL_Connection conn((Client *)&client);

 

// Create an instance of the cursor passing in the connection

 

MySQL_Cursor cur = MySQL_Cursor(&conn);

 

void setup() {

 

Serial.begin(115200);

 

// eglibc ethernet naming...

 

system("ifconfig eth0 192.168.1.222 netmask 255.255.255.0");

 

Serial.println(Ethernet.localIP());

while (!Serial); // wait for serial port to connect

Serial.println("Connecting...");

 

if (conn.connect(server_addr, 3306, user, password)) {

 

delay(1000);

 

}

 

else

 

Serial.println("Connection failed.");

 

}

When I upload the sketch to the galileo and turn on the serial monitor i can see

 

192.168. 1.222

 

Connecting...

and nothing else of the sketch keeps running.

 

I don't know if this is the right place to ask for this, but in your Blog i couldn't do it.

 

Thanks.

Roberto

0 Kudos
4 Replies
FTinetti
Honored Contributor I
106 Views

Hi Roberto,

I don't have any Galileo with MySQL at hand to try, but maybe you can check the following:

1) Why the difference among IPs?:

IPAddress server_addr(192,168,1,100); // IP of the MySQL *server* here

...

system("ifconfig eth0 192.168.1.222 netmask 255.255.255.0");

2) Do the MySQL console work fine?

3) Try with "localhost" instead of the "external" IP address

HTH,

Fernando.

FTinetti
Honored Contributor I
106 Views

Replying to myself just to note that if the MySQL server is not running in the Galileo, then it has to be configured to accept connections from remote hosts.

Fernando.

idata
Community Manager
106 Views

Hi Roberto,

I would like to know if you have checked your network connection with MySQL server. Both, the Galileo and the MySQL server must be in the same network, and as Fernando said, you must setup the MySQL server to permit network connections, also be sure there are not firewalls or port blocking software to prohibit access to the server (MySQL default port is 3306). If you have another computer available, please use it instead Galileo to verify if your user account and permissions used in your sketch can connect to the database server.

Hope this information helps, let us know your results.

Regards,

 

-Yermi

 

idata
Community Manager
106 Views

Hi Roberto,

 

 

I would like to know if try my previous suggestions, and also, if you need more help, please let me know.

 

 

Regards,

 

-Yermi
Reply