lua-resty-mysql icon indicating copy to clipboard operation
lua-resty-mysql copied to clipboard

腾讯云服务器上mysql,使用lua不能访问数据库

Open ACEandMy opened this issue 4 years ago • 2 comments

ngx.header.content_type="application/json;charset=utf8" local cjson = require("cjson") local mysql = require("resty.mysql") local uri_args = ngx.req.get_uri_args() local id = uri_args["id"] local db,err = mysql:new() if not db then ngx.say("failed to instantiate mysql: ",err) return end db:set_timeout(1000) local ok,err,errno,sqlstate = db:connect(){ host = "127.0.0.1", port = 3306, database = "changgou_content", user = "root", password = "123456" } if not ok then ngx.say("failed to connect: ", err, ": ", errno, " ", sqlstate) return end local select_sql = "select url,pic from tb_content where status ='1' and category_id="..id.." order by sort_order" res,err,errno,sqlstate = db:query(select_sql) if not res then ngx.say("bad result: ", err, ": ", errno, ": ", sqlstate, ".") return end db:close() local redis = require("resty.redis") local red = redis:new() red:set_timeout(2000) local ip ="127.0.0.1" local port = 6379 red:connect(ip,port) red:set("content_"..id,cjson.encode(res)) red:close()

浏览器访问:提示 failed to connect: Client does not support authentication protocol requested by server; consider upgrading MySQL client: 1251 08004

ACEandMy avatar Sep 17 '20 15:09 ACEandMy

请尝试更新 mysql开发版本库,如果是centos系统,请以下文章参考更新:https://www.tech-field.org/articles/2021/01/04/1609752680599.html

fc13240 avatar Jan 04 '21 09:01 fc13240

请尝试更新 mysql开发版本库,如果是centos系统,请以下文章参考更新:https://www.tech-field.org/articles/2021/01/04/1609752680599.html

我也遇到了这个问题,至今没解决

Surrin1999 avatar Oct 12 '22 06:10 Surrin1999