admin avatar

MySQL添加最小权限的用户和限制该用户占用系统资源的方法

🕞 by admin





添加MySQL最小权限的用户和限制该用户占用系统资源的方法

一般开IDC或是虚拟主机供应商,合租的可以用到该需求。。

限制MySQL用户的权限,并设置该用户占用系统资源的限制。。。代码如下

1
2
3
4
5
6
7
use mysql;
SHOW COLUMNS FROM `mysql`.`user`;
SELECT `user`, `host`, authentication_string AS `password` FROM `mysql`.`user`;
CREATE USER 'demo'@'127.0.0.1' IDENTIFIED BY 'demo';
GRANT EXECUTE, PROCESS, SELECT, SHOW DATABASES, SHOW VIEW, CREATE USER, FILE, LOCK TABLES, RELOAD, REPLICATION CLIENT, SHUTDOWN, REPLICATION SLAVE, SUPER  ON *.* TO 'demo'@'127.0.0.1' WITH GRANT OPTION MAX_QUERIES_PER_HOUR 100 MAX_UPDATES_PER_HOUR 300 MAX_CONNECTIONS_PER_HOUR 200 MAX_USER_CONNECTIONS 150;
FLUSH PRIVILEGES;
SHOW GRANTS FOR 'demo'@'127.0.0.1';

命令设置了demo用户系统资源限制如下

每小时查询次数为100

每小时更新次数为300

每小时连接次数为200

每小时并行次数为150





写一条评论

Based on Golang + fastHTTP + sdb | go1.16.8 Processed in 0ms