Ubuntu22.04.1上 mosquitto安装及mosquitto-auth-plug 认证插件配置

本文详细介绍了在Ubuntu22.04.1系统上安装mosquitto并配置mosquitto-auth-plug插件,以实现根据MySQL数据库中的用户角色进行权限管理,包括创建用户、设置密码和分配主题访问权限。
摘要由CSDN通过智能技术生成

Ubuntu22.04.1上 mosquitto安装及mosquitto-auth-plug 认证插件配置

1、先上效果,可以根据mysql中mosquitto数据库的不同users角色登陆mosquitto:
SELECT * FROM mosquitto.users;
在这里插入图片描述

id,username,pw,super
1,jjolie,PBKDF2$sha256$901$yZnELWKK4NnaNNJl$+T24etYFlJ7AtliumcehcOtudZGLu9ZH,0
2,a,PBKDF2$sha256$901$yZnELWKK4NnaNNJl$+T24etYFlJ7AtliumcehcOtudZGLu9ZH,0
3,su1,PBKDF2$sha256$901$yZnELWKK4NnaNNJl$+T24etYFlJ7AtliumcehcOtudZGLu9ZH,1
4,S1,PBKDF2$sha256$901$yZnELWKK4NnaNNJl$+T24etYFlJ7AtliumcehcOtudZGLu9ZH,1
5,m1,PBKDF2$sha256$901$yZnELWKK4NnaNNJl$+T24etYFlJ7AtliumcehcOtudZGLu9ZH,0
6,ps1,PBKDF2$sha256$901$yZnELWKK4NnaNNJl$+T24etYFlJ7AtliumcehcOtudZGLu9ZH,0

SELECT * FROM mosquitto.acls;

-- MySQL dump 10.13  Distrib 8.0.32, for Linux (x86_64)
--
-- Host: 127.0.0.1    Database: mosquitto
-- ------------------------------------------------------
-- Server version	8.0.34-0ubuntu0.22.04.1

/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;
/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */;
/*!50503 SET NAMES utf8 */;
/*!40103 SET @OLD_TIME_ZONE=@@TIME_ZONE */;
/*!40103 SET TIME_ZONE='+00:00' */;
/*!40014 SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0 */;
/*!40014 SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0 */;
/*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='NO_AUTO_VALUE_ON_ZERO' */;
/*!40111 SET @OLD_SQL_NOTES=@@SQL_NOTES, SQL_NOTES=0 */;

--
-- Table structure for table `users`
--

DROP TABLE IF EXISTS `users`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!50503 SET character_set_client = utf8mb4 */;
CREATE TABLE `users` (
  `id` int NOT NULL AUTO_INCREMENT,
  `username` varchar(25) NOT NULL,
  `pw` varchar(128) NOT NULL,
  `super` int NOT NULL DEFAULT '0',
  PRIMARY KEY (`id`),
  UNIQUE KEY `users_username` (`username`)
) ENGINE=InnoDB AUTO_INCREMENT=7 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;
/*!40101 SET character_set_client = @saved_cs_client */;

--
-- Dumping data for table `users`
--

LOCK TABLES `users` WRITE;
/*!40000 ALTER TABLE `users` DISABLE KEYS */;
INSERT INTO `users` VALUES (1,'jjolie','PBKDF2$sha256$901$yZnELWKK4NnaNNJl$+T24etYFlJ7AtliumcehcOtudZGLu9ZH',0),(2,'a','PBKDF2$sha256$901$yZnELWKK4NnaNNJl$+T24etYFlJ7AtliumcehcOtudZGLu9ZH',0),(3,'su1','PBKDF2$sha256$901$yZnELWKK4NnaNNJl$+T24etYFlJ7AtliumcehcOtudZGLu9ZH',1),(4,'S1','PBKDF2$sha256$901$yZnELWKK4NnaNNJl$+T24etYFlJ7AtliumcehcOtudZGLu9ZH',1),(5,'m1','PBKDF2$sha256$901$yZnELWKK4NnaNNJl$+T24etYFlJ7AtliumcehcOtudZGLu9ZH',0),(6,'ps1','PBKDF2$sha256$901$yZnELWKK4NnaNNJl$+T24etYFlJ7AtliumcehcOtudZGLu9ZH',0);
/*!40000 ALTER TABLE `users` ENABLE KEYS */;
UNLOCK TABLES;
/*!40103 SET TIME_ZONE=@OLD_TIME_ZONE */;

/*!40101 SET SQL_MODE=@OLD_SQL_MODE */;
/*!40014 SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS */;
/*!40014 SET UNIQUE_CHECKS=@OLD_UNIQUE_CHECKS */;
/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */;
/*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */;
/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */;
/*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */;

-- Dump completed on 2023-08-31 16:17:15

在这里插入图片描述

id,username,topic,rw
1,jjolie,loc/jjolie,1
2,jjolie,loc/ro,1
3,jjolie,loc/rw,2
4,jjolie,$SYS/something,1
5,a,loc/test/#,1
6,a,$SYS/broker/log/+,1
7,su1,/#,1
8,nop,mega/secret,1
9,jog,loc/#,1
10,m1,loc/#,1
11,ps1,x,1
12,ps1,blabla/%c/priv/#,1

-- MySQL dump 10.13  Distrib 8.0.32, for Linux (x86_64)
--
-- Host: 127.0.0.1    Database: mosquitto
-- ------------------------------------------------------
-- Server version	8.0.34-0ubuntu0.22.04.1

/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;
/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */;
/*!50503 SET NAMES utf8 */;
/*!40103 SET @OLD_TIME_ZONE=@@TIME_ZONE */;
/*!40103 SET TIME_ZONE='+00:00' */;
/*!40014 SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0 */;
/*!40014 SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0 */;
/*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='NO_AUTO_VALUE_ON_ZERO' */;
/*!40111 SET @OLD_SQL_NOTES=@@SQL_NOTES, SQL_NOTES=0 */;

--
-- Table structure for table `acls`
--

DROP TABLE IF EXISTS `acls`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!50503 SET character_set_client = utf8mb4 */;
CREATE TABLE `acls` (
  `id` int NOT NULL AUTO_INCREMENT,
  `username` varchar(25) NOT NULL,
  `topic` varchar(256) NOT NULL,
  `rw` int NOT NULL DEFAULT '1',
  PRIMARY KEY (`id`),
  UNIQUE KEY `acls_user_topic` (`username`,`topic`(228))
) ENGINE=InnoDB AUTO_INCREMENT=13 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;
/*!40101 SET character_set_client = @saved_cs_client */;

--
-- Dumping data for table `acls`
--

LOCK TABLES `acls` WRITE;
/*!40000 ALTER TABLE `acls` DISABLE KEYS */;
INSERT INTO `acls` VALUES (1,'jjolie','loc/jjolie',1),(2,'jjolie','loc/ro',1),(3,'jjolie','loc/rw',2),(4,'jjolie','$SYS/something',1),(5,'a','loc/test/#',1),(6,'a','$SYS/broker/log/+',1),(7,'su1','/#',1),(8,'nop','mega/secret',1),(9,'jog','loc/#',1),(10,'m1','loc/#',1),(11,'ps1','x',1),(12,'ps1','blabla/%c/priv/#',1);
/*!40000 ALTER TABLE `acls` ENABLE KEYS */;
UNLOCK TABLES;
/*!40103 SET TIME_ZONE=@OLD_TIME_ZONE */;

/*!40101 SET SQL_MODE=@OLD_SQL_MODE */;
/*!40014 SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS */;
/*!40014 SET UNIQUE_CHECKS=@OLD_UNIQUE_CHECKS */;
/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */;
/*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */;
/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */;
/*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */;

-- Dump completed on 2023-08-31 16:17:15

在这里插入图片描述
在这里插入图片描述
在这里插入图片描述
在这里插入图片描述
在这里插入图片描述
在这里插入图片描述
在这里插入图片描述
2、账号密码 123456


评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

敏捷践行者

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值