SELECT password_hash2 FROM mqtt_user where device_number = ${username} LIMIT 1
在数据库中把password_hash字段改为password_hash2,这样就登录不上了。
如果两边字段都为password_hash能正常登录。
请问查询字段必须是password_hash吗
图片所示,这样是登录不上的
SELECT password_hash2 FROM mqtt_user where device_number = ${username} LIMIT 1
在数据库中把password_hash字段改为password_hash2,这样就登录不上了。
如果两边字段都为password_hash能正常登录。
请问查询字段必须是password_hash吗
不是必须的,你可以开debug日志看看是什么错
好的,我现在试试
2025-04-08T11:18:55.426000+08:00 [debug] msg: mqtt_packet_received, mfa: emqx_channel:handle_in/2(331), peername: 27.221.155.122:19931, clientid: mqttx_cddc5295, packet: CONNECT(Q0, R0, D0, ClientId=mqttx_cddc5295, ProtoName=MQTT, ProtoVsn=5, CleanStart=true, KeepAlive=60, Username=admin, Password=****), tag: MQTT
2025-04-08T11:18:55.426000+08:00 [debug] msg: mysql_connector_received, mfa: emqx_mysql:on_sql_query/6(460), peername: 27.221.155.122:19931, clientid: mqttx_cddc5295, connector: <<“emqx_authn_mysql:3”>>, sql: emqx_authn_mysql, state: #{pool_name => <<“emqx_authn_mysql:3”>>,prepares => ok,query_templates => #{{emqx_authn_mysql,prepstmt} => {[<<“SELECT password_hash22222222 FROM mqtt_user where device_number = ? LIMIT 1”>>],}}}, tag: QUERY
2025-04-08T11:18:55.430000+08:00 [debug] msg: authenticator_result, mfa: emqx_authn_chains:authenticate_with_provider/2(686), peername: 27.221.155.122:19931, clientid: mqttx_cddc5295, authenticator: <<“password_based:mysql”>>, result: {error,not_authorized}, tag: AUTHN
2025-04-08T11:18:55.430000+08:00 [debug] msg: authentication_result, mfa: emqx_authn_chains:authenticate/2(166), peername: 27.221.155.122:19931, clientid: mqttx_cddc5295, reason: chain_result, result: {stop,{error,not_authorized}}, tag: AUTHN
麻烦您了,您看看这几条日志能看出哪里出错了吗
你的数据库字段名不是只有一个2么,这写的sql的2有8个
您好,我为了区分把两边都改了
025-04-08T13:00:38.613000+08:00 [debug] msg: raw_bin_received, mfa: emqx_connection:when_bytes_in/3(778), peername: 27.221.155.122:20274, bin: 103300044D51545405C2003C09110000000019001700000E6D717474785F6364646335323935000561646D696E0006313233343536, size: 53, type: hex
2025-04-08T13:00:38.613000+08:00 [debug] msg: mqtt_packet_received, mfa: emqx_channel:handle_in/2(331), peername: 27.221.155.122:20274, clientid: mqttx_cddc5295, packet: CONNECT(Q0, R0, D0, ClientId=mqttx_cddc5295, ProtoName=MQTT, ProtoVsn=5, CleanStart=true, KeepAlive=60, Username=admin, Password=******), tag: MQTT
2025-04-08T13:00:38.614000+08:00 [debug] msg: mysql_connector_received, mfa: emqx_mysql:on_sql_query/6(460), peername: 27.221.155.122:20274, clientid: mqttx_cddc5295, connector: <<“emqx_authn_mysql:3”>>, sql: emqx_authn_mysql, state: #{pool_name => <<“emqx_authn_mysql:3”>>,prepares => ok,query_templates => #{{emqx_authn_mysql,prepstmt} => {[<<“SELECT password_hash22222222 FROM mqtt_user where device_number = ? LIMIT 1”>>],}}}, tag: QUERY
2025-04-08T13:00:38.616000+08:00 [debug] msg: authenticator_result, mfa: emqx_authn_chains:authenticate_with_provider/2(686), peername: 27.221.155.122:20274, clientid: mqttx_cddc5295, authenticator: <<“password_based:mysql”>>, result: {error,not_authorized}, tag: AUTHN
2025-04-08T13:00:38.616000+08:00 [debug] msg: authentication_result, mfa: emqx_authn_chains:authenticate/2(166), peername: 27.221.155.122:20274, clientid: mqttx_cddc5295, reason: chain_result, result: {stop,{error,not_authorized}}, tag: AUTHN
2025-04-08T13:00:38.617000+08:00 [debug] msg: mqtt_packet_sent, mfa: emqx_connection:serialize_and_inc_stats_fun/1(877), peername: 27.221.155.122:20274, clientid: mqttx_cddc5295, packet: CONNACK(Q0, R0, D0, AckFlags=0, ReasonCode=135), tag: MQTT
2025-04-08T13:00:38.617000+08:00 [debug] msg: emqx_connection_terminated, mfa: emqx_connection:terminate/2(668), peername: 27.221.155.122:20274, clientid: mqttx_cddc5295, reason: {shutdown,not_authorized}, tag: SOCKET
2025-04-08T13:00:38.617000+08:00 [info] msg: terminate, mfa: emqx_connection:terminate/2(673), peername: 27.221.155.122:20274, clientid: mqttx_cddc5295, reason: {shutdown,not_authorized}
请问这个报错代表什么意思:result: {error,not_authorized}, tag: AUTHN
https://github.com/emqx/emqx/blob/master/apps%2Femqx_auth%2Fsrc%2Femqx_authn%2Femqx_authn_utils.erl#L81-L88
不好意思,刚看了一下代码应该是,写死的password_hash,以前不是这样的 不知道什么时候改成这样的。。。
好的,谢谢你,我想想办法