openresty / lua-resty-mysql

Nonblocking Lua MySQL driver library for ngx_lua or OpenResty
708 stars 236 forks source link

Client does not support authentication protocol requested by server; consider upgrading MySQL client: 1251 08004 #147

Open ckall opened 9 months ago

ckall commented 9 months ago

code:

  local mysql = require("resty.mysql")
  local db, err = mysql:new()
    if not db then
        return 500, { message = "failed to instantiate mysql: " .. err }
    end
    db:set_timeout(1000)
    local ok,errcode, sqlstate
     ok, err, errcode, sqlstate = db:connect{
        host = "127.0.0.1",
        port = 3306,
        database = "apisix_test",
        user = "root",
        password = "apisixrootpassword"
        charset = "utf8",
        max_packet_size = 1024 * 1024,
    }
    if not ok then
        return 500, { message = "failed to connect: " .. err .. ": " .. errcode .. " " .. sqlstate }
    end

resp:

{
    "message": "failed to connect: Client does not support authentication protocol requested by server; consider upgrading MySQL client: 1251 08004"
}

How can I solve it? Does it feel like an issue with the latest version of MySQL?

zhuizhuhaomeng commented 9 months ago

Which version of MySQL server do you use?