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","xuz@abc.com");

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','lua@gmail.com')"))

 

 

 

Write comment (0 Comments)

In case no internet or deploying a large number of Yun. The local packages repository will help.

mkdir -p ~/ipk
cd ~/ipk
wget http://downloads.arduino.cc/openwrtyun/1/packages/Packages
cat Packages | grep "Filename: " >downloadfile.txt
sed -i 's/Filename: /http:\/\/downloads.arduino.cc\/openwrtyun\/1\/packages\//g' downloadfile.txt

 

sudo apt-get install -y aria2
time aria2c -x 16 -i  downloadfile.txt

 

...
Status Legend:
(OK):download completed.

real    0m56.810s
user    0m3.708s
sys     0m6.676s


Change feed to local:

nano /etc/opkg.conf
#src/gz attitude_adjustment http://downloads.arduino.cc/openwrtyun/1/packages
src/gz local file:////mnt/sda1/packages
opkg update

 



Write comment (1 Comment)

Subcategories

Expand the Storage at Yun

Languages Supported by Yun

Backup and Recover

Network and Yun

Hardware & Yun

OpenWrt-SDK & Yun