版本:EMQX 5.0
按照官方文档,进行 认证配置,选择 MySQL ,根据文档提供的 SQL 创建数据库和表,插入数据,创建完成后提示 MySQL 已断开,这个正常么 ?
可以看下EMQX的后台日志,一般不是网络问题就是认证失败
数据库名要写对
数据库建表
CREATE TABLE mqtt_user
(
id
int(11) unsigned NOT NULL AUTO_INCREMENT,
username
varchar(100) DEFAULT NULL,
password_hash
varchar(100) DEFAULT NULL,
salt
varchar(35) DEFAULT NULL,
is_superuser
tinyint(1) DEFAULT 0,
created
datetime DEFAULT NULL,
PRIMARY KEY (id
),
UNIQUE KEY mqtt_username
(username
)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
然后就可以了
这个并没有问题
我使用的是 Docker 的版本 , Docker 运行的时候需要开启 3306 端口么?
我遇到了同样的问题
本地docker安装的 5.8.1
本地数据库系统是mysql 8,创建了一个数据库(schema)并在内部创建了对应的表
我可以确定我填写的数据库链接,数据库名以及账号密码是正确的
并且在navicat 得到了验证,但是我无法连接到数据库,上面展示状态已断开
docker后台打印如下
2024-10-20T10:20:50.049237+00:00 [error] crasher: initial call: mysql_conn:init/1, pid: <0.4756.0>, registered_name: , exit: {econnrefused,[{gen_server,init_it,6,[{file,“gen_server.erl”},{line,961}]},{proc_lib,init_p_do_apply,3,[{file,“proc_lib.erl”},{line,241}]}]}, ancestors: [<0.4755.0>,<0.4754.0>,<0.4752.0>,ecpool_sup,<0.2975.0>], message_queue_len: 0, messages: , links: [<0.4755.0>], dictionary: , trap_exit: false, status: running, heap_size: 233, stack_size: 28, reductions: 291; neighbours:
2024-10-20T10:20:50.049698+00:00 [error] crasher: initial call: ecpool_worker:init/1, pid: <0.4755.0>, registered_name: , exit: {econnrefused,[{gen_server,init_it,6,[{file,“gen_server.erl”},{line,961}]},{proc_lib,init_p_do_apply,3,[{file,“proc_lib.erl”},{line,241}]}]}, ancestors: [<0.4754.0>,<0.4752.0>,ecpool_sup,<0.2975.0>], message_queue_len: 0, messages: , links: [<0.4754.0>], dictionary: , trap_exit: true, status: running, heap_size: 376, stack_size: 28, reductions: 275; neighbours:
2024-10-20T10:20:50.050001+00:00 [error] Supervisor: {<0.4754.0>,ecpool_worker_sup}. Context: start_error. Reason: econnrefused. Offender: id={worker,1},pid=undefined.
2024-10-20T10:20:50.050111+00:00 [error] Supervisor: {<0.4752.0>,ecpool_pool_sup}. Context: start_error. Reason: {shutdown,{failed_to_start_child,{worker,1},econnrefused}}. Offender: id=worker_sup,pid=undefined.
2024-10-20T10:20:50.050727+00:00 [warning] tag: RESOURCE, msg: start_ecpool_error, reason: econnrefused, resource_id: <<“emqx_authz_mysql:25”>>
2024-10-20T10:20:50.050942+00:00 [warning] tag: AUTHZ/MYSQL, msg: start_resource_failed, reason: {start_pool_failed,<<“emqx_authz_mysql:25”>>,econnrefused}, resource_id: <<“emqx_authz_mysql:25”>>
我尝试直接建了一个旧密码规则的用户,仍然存在问题
2024-10-20T12:48:42.301329+00:00 [warning] tag: RESOURCE, msg: start_ecpool_error, reason: econnrefused, resource_id: <<“emqx_authz_mysql:8”>>
2024-10-20T12:48:42.301406+00:00 [warning] tag: AUTHZ/MYSQL, msg: start_resource_failed, reason: {start_pool_failed,<<“emqx_authz_mysql:8”>>,econnrefused}, resource_id: <<“emqx_authz_mysql:8”>>