Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
ACEandMy opened this issue Sep 17, 2020 · 2 comments
Open

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

ACEandMy opened this issue Sep 17, 2020 · 2 comments

Comments

@ACEandMy
Copy link

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

@fc13240
Copy link

fc13240 commented Jan 4, 2021

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

@Surrin1999
Copy link

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

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants