admin avatar

MySQL adds the user with the least authority and the method of restricting the user to occupy system resources

🕞 by admin





Add the user with the least privilege of MySQL and the method to restrict the user to occupy system resources

Generally open IDC or virtual hosting provider, the co-leasing can use this demand. .

Limit the permissions of the MySQL user and set restrictions on the user's occupation of system resources. . . code show as below

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';

The command sets the demo user system resource limits as follows

100 queries per hour

300 updates per hour

200 connections per hour

150 parallels per hour





💘 相关文章





写一条评论

Based on Golang + fastHTTP + sdb | go1.18.1 Processed in 1ms