Expand mySQL Capabilities?

27 Apr 2011

I've been using the mySQL Client Example provided by Donatien. It has worked very well. The current client is uni-directional in that data can be sent to a mySQL server, but not received back from the server. An SQL string can be sent to the server, and some status info will be returned.

I now need to enhance my application to be able to receive some info from the server. I do not have to perform full blown data queries, but instead need to know if a TABLE or DATABASE exists on that server.

The mySQL routines that Donatien has written allow for an embedded SQL string to be sent, which means that a "SELECT * FROM mytable" could be sent by his routines. If this SELECT was sent, I have no idea how or where the returned data would goif anywhere at all.

I'm willing to try to write this enhanced code to handle returning data, but haven't located a source explaining how to do that. I've spent a couple of hours searching the mySQL website, but cannot find any starting info on this topic.

Donatien: Would you be willing to share your mySQL Class code so that I could build on it. I would certainly be willing to contribute back any code that I enhance from it. Or if that is not OK, can you provide me with information on how you started your mySQL development?

Thanks and Regards, Doug Wendelboe

27 Apr 2011

Hi Doug

Is this Donatien's source code that you are after here http://mbed.org/users/donatien/programs/NetServicesSource/5zh9t/docs/MySQLClient_8cpp_source.html?

Regards
Daniel

28 Apr 2011

Hi Daniel:

Thanks for the URL of this code. At first glance it looks like it might be. It has the net interface state machine and such. I'll study it further today and let you know how it looks. Thanks again.

Doug

21 Feb 2012

Hi Doug

I am trying to insert data to my local xampp server. But It shows error 9 while opening mySQL connection. Looking for your answer.

Bye.

21 Feb 2012

Hi Atanu Barai,

I've also encountered error 9 while opening a mySQL connection. This error comes from the server that is configured to refuse remote connections. I have solved this problem by changing the line:

bind-address            = 127.0.0.1

to:

bind-address            = 0.0.0.0

This allows the mySQL server to accept network connections not coming from the local host. You need to make these changes in the mySQL server configuration file. Debian places this file at /etc/mysql/my.cnf by default.

With kind regards,

Dennis Kofflard

21 Feb 2012

Hi Dennis Kofflard,

Thank you very much. Now the ERROR 9 problem has been solved. :)

But now there is showing error 2, that is protocol error I think. Don't know how to fix this.

Regards,

Atanu Barai

21 Feb 2012

Hi Atanu Barai,

I remember having error 2. I do not remember what the problem was and how I fixed it, if you could give me some more details I might remember what the problem was and how I fixed it.

With kind regards,

Dennis Kofflard

21 Feb 2012

Hi Dennis Kofflard,

Thanks for quick reply. Here is the code. I am on xampp server installed on windows 7. mySQL version MySQL 5.5.16 -------- /media/uploads/hack08/code.txt

22 Feb 2012

Dear Atanu Barai,

Is this the output you get from the mbed ?

Ethernet Connection Setup Success

Error 2 in opening mysql connection

Error 3 during SQL Command

If so the problem might be that the user you login with on the mySQL server does not have rights to write to that specific table. I had to allow my 'mbed' user acces from all ip adresses. The default is to only allow localhost acces so when you want to write to the database from a different ip adress it triggers an error. With to program 'MySQL Administrator' on ubuntu I gave my mbed user acces from all ip adresses, it looks like this:

/media/uploads/DennisKofflard/mysql_user_rights.png

With kind regards,

Dennis Kofflard

23 Feb 2012

Dennis Kofflard, Thank you. Now its running fine. :)

26 Apr 2017

Dennis Kofflard wrote:

Dear Atanu Barai,

Is this the output you get from the mbed ?

Ethernet Connection Setup Success

Error 2 in opening mysql connection

Error 3 during SQL Command

If so the problem might be that the user you login with on the mySQL server does not have rights to write to that specific table. I had to allow my 'mbed' user acces from all ip adresses. The default is to only allow localhost acces so when you want to write to the database from a different ip adress it triggers an error. With to program 'MySQL Administrator' on ubuntu I gave my mbed user acces from all ip adresses, it looks like this:

/media/uploads/DennisKofflard/mysql_user_rights.png

With kind regards,

Dennis Kofflard

Hello guys! I still have this issue after trying all of these..., someone could provide some help? Thanks!

LE: If I'm using the updated libraries, I get all kind of errors... like libraries missing.(example.h couldn't be found etc.)

29 Apr 2017

Dear Anghel Catalin Robert,

It has been a while since I've worked with this but I'll try to help.

Please execute the following command in the mysql server to check the privileges of the user you are trying to use from the mbed: Please change the mbed user and mbed host to the correct values.

mysql show grants

SHOW GRANTS FOR 'MBED_USER'@'MBED_HOST';

It is important to remember that mysql permissions are set on a username+hostname pair and not just on a username by itself. This means that when you grant permissions to mbed@ip1 and you connect from ip2 with the mbed user you username+hostname pair is then mbed@ip2 and then you will get an permission denied. The easiest solution is to re-create your mbed user with a wildcard hostname (=anything is okay) as 'mbed'@'%'

something like this would fix it:

create new user

CREATE USER 'mbed'@'%' IDENTIFIED BY 'password';
GRANT ALL PRIVILEGES ON somedb.* to 'mbed'@'%';

Kind regards, Dennis Kofflard

29 Apr 2017

/media/uploads/CatalinRobert/sqluser.png

Hi! With all my regards, I did these things and without succes! The problem has been solved using another way but I'm still interested how we're gonna fix this issue!

Later edit: These are the things that I have done till now. Created some different users with different access to the MySQL server(local). I have turned off the firewall, the antivirus, checked if my firewall restricted access to sql port, if there are inbound/outbound rules. I checked if MySQL could be accesed through port 3306 using telnet and it works only for 10-15 seconds, it returns a string(it;s a little bit weird) and after that the connection is lost. My mbed user has all the privileges required to access the MySQL server!