openresty / lua-resty-mysql

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

Client does not support charset utf8mb4_0900_ai_ci'; #150

Open pinksuko opened 2 months ago

pinksuko commented 2 months ago

mysql: 8.4.2 code:

 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