配置文件mosquitto.conf
#设置不允许匿名登录 allow_anonymous false #设置账户密码文件位置为C:\pwfile.example password_file c:/pwfile.example
保存配置文件。
命令行执行
mosquitto_passwd -c /MosquittoTest/pwfile.example VincentZhou (使用-c 参数会导致清空密码文件,重新插入用户)
mosquitto_passwd /MosquittoTest/pwfile.example VicentZhou (不使用-c 表示追加用户,不影响旧用户)
重启服务就ok啦。