function _M.new()
local db, err = mysql:new()
if not db then
ngx.log(ngx.ERR, "failed to instantiate mysql: ", err)
return nil, err
end
db:set_timeout(1000) --1 second
local ok, err = db:connect {
host = "127.0.0.1",
port = 3306,
database = "master_db",
user = "pinksuko",
password = "suda.123",
charset = "utf8mb4",
max_packet_size = 1024 * 1024,
}
if not ok then
ngx.log(ngx.ERR, "failed to connect: ", err)
return nil, err
end
return db
end
error.log:
failed to connect: charset 'utf8mb4_0900_ai_ci' is not supported
mysql: 8.4.2 code:
error.log: