12345678910111213141516171819require "luasql.mysql"env = luasql.mysql()-- 连接数据库conn = env:connect("数据库名", "用户名", "密码", "IP地址", 端口)-- 设置数据库的编码格式conn:execute"SET NAMES UTF8"-- 执行数据库操作cur = conn:execute("sql语句")row = cur:fetch({},"a")-- 关闭数据库连接conn:close()-- 关闭数据库环境env:close() 注 Lua >= 5.2 1mysql = require "luasql.mysql"