1、进入到安装目录下: cd /usr/local/Cellar/mosquitto/1.3.5/sbin 2、启动mosquitto服务: ./mosquitto -c /usr/local/Cellar/mosquitto/1.3.5/etc/mosquitto/mosquitto.conf -d 3、订阅: mosquitto_sub -h 123.123.123.122 -p 8080 -u username -P pasword -t yourtop 4、发布: mosquitto_pub -h 123.123.123.123 -p 8080 -u username -P password -m someMessage -t yourtop 至于mosquitto的安装,可以通过homebrew来安装,