1. Create test db at mysql server for test purpose.
mysql> CREATE DATABASE books; mysql> USE books; mysql> CREATE TABLE authors (id INT, name VARCHAR(20), email VARCHAR(20)); mysql> SHOW TABLES; mysql> INSERT INTO authors (id,name,email) VALUES(1,"Vivek","[email protected]");
2. Grant access right for remote client. It might need modify my.cnf.
GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' IDENTIFIED BY 'password';
3. Use Lua to insert data
opkg update opkg install luasql-mysql
nano mysql.lua
#!/usr/bin/lua require "luasql.mysql" env = assert (luasql.mysql()) con = assert (env:connect('books', 'root', 'password', '192.168.0.20')) res = assert (con:execute("INSERT INTO authors (id,name,email) VALUES(2,'lua','[email protected]')"))
Comments powered by CComment