EMQX配置 用户名和密码认证方式连接

1, 找到mqtt 的 /etc/plugins/ 文件夹下的emqx_auth_mnesia.conf 文件
在这里插入图片描述2 ,vim打开编辑该文件 根据例子添加账号密码 并保存

auth.user.1.username = xxx
auth.user.1.password = 123456

在这里插入图片描述

3, 打开EMQX后台, 找到插件 ,启动该插件, 随后就可以了

在这里插入图片描述
4,修改etc/emqx.conf 配置文件 如下
下面是禁用匿名连接,禁用之后, 配置的 账号密码才能生效
vim 查找 /allow_anonymous

# etc/emqx.conf
 
## Allow anonymous authentication by default if no auth plugins loaded.
## Notice: Disable the option in production deployment!
##
## Value: true | false
allow_anonymous = false
 
## Allow or deny if no ACL rules matched.
##
## Value: allow | deny
acl_nomatch = deny

5, 重启emqtt服务,生效