Hello!
On Fri, Aug 10, 2012 at 9:14 PM, micol im wrote:
> 您好,我在使用lua-resty-mysql 遇到连接问题,能不能帮我看看,谢谢了
>
> 这个是我的代码
> db:set_timeout(1000);
> local ops = {
> ["host"] = "127.0.0.1",
> ["port"] = 3306,
> ["database"] = "test",
> ["user"] = "root",
> ["password"] = "123456",
> ["max_packet_size"] = 1024 * 1024
> }
> local ok, err, errno, sqlstate = db:connect(ops);
>
> 下面是报的错
> lua handler aborted: runtime error:
> /root/www/module/lib/resty/mysql.lua:483: ngx.socket connect: expecting 2 or
> 3 arguments (including the object), but seen 4
> stack traceback:
> [C]: in function 'connect'
> /root/www/module/lib/resty/mysql.lua:483: in function 'connect'
这个错误是因为你使用了版本过老的 ngx_lua 或者 ngx_openresty 所导致的。引用一下 lua-resty-mysql 的
README 中的原文:
“Note that at least [ngx_lua
0.5.7](https://github.com/chaoslawful/lua-nginx-module/tags) or
[ngx_openresty 1.2.1.7](http://openresty.org/#Download) is required.”
所以建议升级到最新的 ngx_lua 0.5.12 或者 ngx_openresty 1.2.1.11 :)
Best regards,
-agentzh
P.S. 同时抄送给 openresty 邮件列表:https://groups.google.com/group/openresty 也欢迎你加入 :)