主要参考:
luasql安装, 在终端通过yum命令安装:
yum -y install lua-sql
接下来写个测试的lua脚本文件(通过lua连接mysql数据库),如:
#!/usr/bin/lualocal luasql = require "luasql.mysql"local env = assert(luasql.mysql())local con = assert(env:connect("mysql", "root", "123", "192.168.1.90", 3306))local cur = assert(con:execute("show databases"))local row = cur:fetch ({}, "a") while row do print(row.Database) row = cur:fetch (row, "a")endcur:close()con:close()env:close()
运行结果:
[zcm@vm-fedora20 lua]$ ./mysql.lua information_schemamysqlperformance_schemasakilatestworld