hello,春哥
最近在用openresty操作mongo时
发现这么一个问题:
MongoDB shell version: 3.0.4
connecting to: 127.0.0.1:27018/zy_base
db.auth('zy_base', '1qaz2wsx')
1
命令行执行是成功的
然后我在openresty下操作
代码如下:
local function test_init( )
mongo = require "resty.mongol";
bson = require "resty.mongol.bson";
object_id = require "resty.mongol.object_id";
local _mongo_conn = mongo:new()
_mongo_conn:set_timeout(30*1000); -- 60 seconds
local _ok, _err = _mongo_conn:connect( "127.0.0.1:27018" )
if not _ok then
return ;
end
return _mongo_conn:new_db_handle( 'zy_base' ), _mongo_conn;
end;
local dbt, _ = test_init();
local code, err = dbt:auth('zy_base', '1qaz2wsx')
ngx.log(ngx.NOTICE,"========================="..tostring(err))
提示auth failed,不知道是哪里出了问题
恳请不吝赐教