OpenWrt Forum Archive

Topic: MySQL client

The content of this topic has been archived on 15 Apr 2018. There are no obvious gaps in this topic, but there may still be some posts missing at the end.

Hi!
I would like to use OpenWRT on a 703n to insert data into a external MySQL server.  But how?

I installed libmysqlclient , but that did not help me much. I do not understand how to use it. There is no mysql executable.
And Mysql server will not fit on the 703n.

Any help is appreciated!
Thanks!

I need a smal mySQL client for OpenWRT!

I been searching some more, but not found anything that I can use.

any tip is welcome!

- Is it possible to extract some parts of the mySQLServer package to make it fit in a 703n
- Can I use the mysqlclient package - How?

Thanks a million for any help!

haven't tried it myself but there's a luasql-mysql package you can use

and http://www.keplerproject.org/luasql/manual.html

there's also python, but that's 2MB just for the base package so it prob won't fit whereas you already have lua if you installed luci.

Thanks. Good idea!

I have installed and again i have new learning curve ahead of me :-)

Anyone experienced with lua?

I have connected to my database (i think)
But I dont understand how to get somethingg out of it. I.e how to make a SQL statement like  "SELECT * from fum"

This is what I have.
#!/usr/bin/lua
require "luasql.mysql"
env = assert (luasql.mysql())
env:connect("192.168.1.34", "user", "pass", "foo", 3306)


Thanks for any help!!

This is working as a MySQL client now:

:-)


#!/usr/bin/lua
require "luasql.mysql"
env = assert (luasql.mysql())
con = assert (env:connect('test', 'test', 'test', '192.168.10.16'))
res = con:execute(string.format( "INSERT INTO test VALUES ('test', 'test')" , test1, test2) )
cur:close()

Hi, sorry I'm not a native English speaker. Can you teach me how to install luasql on OpenWRT, I stuck at this step for days... Thanks you very much

(Last edited by duong.tran on 29 Nov 2013, 05:53)

opkg update
opkg install luasql-mysql

   vi test.lua

#!/usr/bin/lua
require "luasql.mysql"
env = assert (luasql.mysql())
con = assert (env:connect('database', 'login, 'password', '192.168.10.10'))
res = assert (con:execute(string.format( "INSERT INTO testable (one,two,three,four) VALUES (%s,%s,'DBTest',now())", variable1,variable2)))

Thank you for your guide, it was very detail. However I decide to use socket, I think it will be a little more secure because the router was setup at client's site, so I don't want to put the username and password near their hands. ^^, but thanks again for your help.

You can take mysql client binary from mysql server package. If it is too big to install - unpack it and take only needed binary

(Last edited by bolvan on 6 Dec 2013, 20:35)

Please explain how You solved it.
Are You connecting OpenWrt to MySql via socket?

thanks

bolvan wrote:

You can take mysql client binary from mysql server package. If it is too big to install - unpack it and take only needed binary


I tried this. but it is not sufice wiith only the mysql binary. You need som libraries and stuff.
Using luasql-mysql is about 268kB and mysql client takes 590kB.
It will fit, but leavs not much space left for other things.
I stick with the awkward lua for now.

I am still courios how this can be solved with sockets, as mentioned in an earlier post

If you configure the mysql server to listen on a lan ip and port instead of a unix socket you could use the mysql client from cli. That way installing the mysql client will  give you the option to operate against the server from openwrt(You would have to specify the host flag on  the mysql client interface). If mysql server is listening on a unix socket you would have to connect to it from the same host.

(Last edited by gkarakou on 8 Dec 2013, 10:56)

The discussion might have continued from here.