30 lines
1.6 KiB
SQL
30 lines
1.6 KiB
SQL
create database if not exists emqx DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_bin;
|
||
use emqx;
|
||
CREATE TABLE `mqtt_user` (
|
||
`id` int(11) unsigned NOT NULL AUTO_INCREMENT comment 'id',
|
||
`username` varchar(100) DEFAULT NULL comment '用户名',
|
||
`password_hash` varchar(100) DEFAULT NULL comment '密码',
|
||
`salt` varchar(35) DEFAULT NULL comment '盐',
|
||
`is_superuser` tinyint(1) DEFAULT 0 comment '是否是超管',
|
||
`created` datetime DEFAULT NULL comment '创建时间',
|
||
PRIMARY KEY (`id`),
|
||
UNIQUE KEY `uniq_mqtt_username` (`username`)
|
||
) ENGINE = InnoDB DEFAULT CHARSET = utf8mb4 comment 'mqtt用户表';
|
||
CREATE TABLE `mqtt_acl` (
|
||
`id` int(11) unsigned NOT NULL AUTO_INCREMENT comment 'id',
|
||
`username` varchar(100) NOT NULL comment '用户',
|
||
`permission` varchar(5) NOT NULL comment '权限 allow 和 deny',
|
||
`action` varchar(9) NOT NULL comment '动作 publish、subscribe 和 all',
|
||
`topic` varchar(100) NOT NULL comment '主题',
|
||
`qos` tinyint(1) comment '可选值为 0、1、2,也可以用 , 分隔的字符串指定多个 QoS,例如 0,1。默认为全部 QoS',
|
||
`retain` tinyint(1) comment '可选)用于指定当前规则是否支持发布保留消息,可选值有 0、1,默认允许保留消息',
|
||
INDEX idx_username(username),
|
||
PRIMARY KEY (`id`)
|
||
) ENGINE = InnoDB DEFAULT CHARSET = utf8mb4 comment 'mqtt权限表';
|
||
alter table mqtt_user
|
||
add is_del bit default b'0' null comment '是否删除';
|
||
|
||
alter table mqtt_acl
|
||
add is_del bit default b'0' null comment '是否删除';
|
||
alter table mqtt_acl
|
||
add is_data bit default b'0' null comment '是否是数据(探测目标)'; |