emqx_auth_mysql组件加载不了

环境信息

  • EMQX 版本:4.1
  • 操作系统及版本:ubuntu20.0.4
  • 其他:mysql8.0.29

问题描述

{emqx_auth_mysql, {bad_return, {{emqx_auth_mysql_app,start,[normal,[]]}, {'EXIT', {{badmatch, {error, {shutdown, {failed_to_start_child,emqx_auth_mysql, {shutdown, {failed_to_start_child,worker_sup, {shutdown, {failed_to_start_child, {worker,1}, {{auth_method,<<"caching_sha2_password">>}, [{mysql_protocol,build_handshake_response,5, [{file, "/emqx-enterprise-rel/_checkouts/mysql/src/mysql_protocol.erl"}, {line,386}]}, {mysql_protocol,handshake,7, [{file, "/emqx-enterprise-rel/_checkouts/mysql/src/mysql_protocol.erl"}, {line,72}]}, {mysql_conn,init,1, [{file, "/emqx-enterprise-rel/_checkouts/mysql/src/mysql_conn.erl"}, {line,111}]}, {gen_server,init_it,2,[{file,"gen_server.erl"},{line,374}]}, {gen_server,init_it,6,[{file,"gen_server.erl"},{line,342}]}, {proc_lib,init_p_do_apply,3, [{file,"proc_lib.erl"},{line,249}]}]}}}}}}}}}, [{emqx_auth_mysql_app,start,2, [{file, "/emqx-enterprise-rel/_checkouts/emqx_auth_mysql/src/emqx_auth_mysql_app.erl"}, {line,38}]}, {application_master,start_it_old,4, [{file,"application_master.erl"},{line,277}]}]}}}}}

配置文件及日志

##--------------------------------------------------------------------
## MySQL Auth/ACL Plugin
##--------------------------------------------------------------------

## MySQL server address.
##
## Value: Port | IP:Port
##
## Examples: 3306, 127.0.0.1:3306, localhost:3306
auth.mysql.server = 10.230.117.73:3306

## MySQL pool size.
##
## Value: Number
auth.mysql.pool = 8

## MySQL username.
##
## Value: String
auth.mysql.username = root

## MySQL password.
##
## Value: String
auth.mysql.password = xjqxz

## MySQL database.
##
## Value: String
auth.mysql.database = mqtt

## MySQL query timeout
##
## Value: Duration
auth.mysql.query_timeout = 5s

## Variables: %u = username, %c = clientid

## Authentication query.
##
## Note that column names should be 'password' and 'salt' (if used).
## In case column names differ in your DB - please use aliases,
## e.g. "my_column_name as password".
##
## Value: SQL
##
## Variables:
##  - %u: username
##  - %c: clientid
##  - %C: common name of client TLS cert
##  - %d: subject of client TLS cert
##
auth.mysql.auth_query = select password from mqtt_user where username = '%u' limit 1
## auth.mysql.auth_query = select password_hash as password from mqtt_user where username = '%u' limit 1

## Password hash.
##
## Value: plain | md5 | sha | sha256 | bcrypt
auth.mysql.password_hash = sha256

## sha256 with salt prefix
## auth.mysql.password_hash = salt,sha256

## bcrypt with salt only prefix
## auth.mysql.password_hash = salt,bcrypt

## sha256 with salt suffix
## auth.mysql.password_hash = sha256,salt

## pbkdf2 with macfun iterations dklen
## macfun: md4, md5, ripemd160, sha, sha224, sha256, sha384, sha512
## auth.mysql.password_hash = pbkdf2,sha256,1000,20

## Superuser query.
##
## Value: SQL
##
## Variables:
##  - %u: username
##  - %c: clientid
##  - %C: common name of client TLS cert
##  - %d: subject of client TLS cert
##
auth.mysql.super_query = select is_superuser from mqtt_user where username = '%u' limit 1

## ACL query.
##
## Value: SQL
##
## Variables:
##  - %a: ipaddr
##  - %u: username
##  - %c: clientid
##
## Note: You can add the 'ORDER BY' statement to control the rules match order
## auth.mysql.acl_query = select allow, ipaddr, username, clientid, access, topic from mqtt_acl ## where ipaddr = '%a' or username = '%u' or username = '$all' or clientid = '%c'

是由于 emqx 4.1 不支持 mysql8 默认的认证密码加密方式。解决方案

  1. 常见错误 | EMQX 企业版
  2. 使用最新的 emqx v4.4.5