您的当前位置:首页 >时尚 >MySQL查看及杀掉链接方法大全 正文

MySQL查看及杀掉链接方法大全

时间:2025-11-05 02:52:33 来源:网络整理编辑:时尚

核心提示

复制#普通用户只能看到当前用户发起的链接 mysql>selectuser(); +--------------------+

MySQL查看及杀掉链接方法大全
复制# 普通用户只能看到当前用户发起的看及链接  mysql> selectuser();  +--------------------+ | user()             |  +--------------------+ | testuser@localhost |  +--------------------+ 1 row inset (0.00 sec)  mysql> show grants;  +----------------------------------------------------------------------+ | Grants for testuser@%                                                |  +----------------------------------------------------------------------+ | GRANT USAGE ON *.* TOtestuser@%                                 |  | GRANTSELECT, INSERT, UPDATE, DELETEON `testdb`.* TOtestuser@% |  +----------------------------------------------------------------------+ 2 rowsinset (0.00 sec)  mysql> show processlist;  +--------+----------+-----------+--------+---------+------+----------+------------------+ | Id     | User     | Host      | db     | Command | Time | State    | Info             |  +--------+----------+-----------+--------+---------+------+----------+------------------+ | 769386 | testuser | localhost | NULL   | Sleep   |  201 |          | NULL             |  | 769390 | testuser | localhost | testdb | Query   |    0 | starting | show processlist |  +--------+----------+-----------+--------+---------+------+----------+------------------+ 2 rowsinset (0.00 sec)  mysql> select * from information_schema.processlist;  +--------+----------+-----------+--------+---------+------+-----------+----------------------------------------------+ | ID     | USER     | HOST      | DB     | COMMAND | TIME | STATE     | INFO                                         |  +--------+----------+-----------+--------+---------+------+-----------+----------------------------------------------+ | 769386 | testuser | localhost | NULL   | Sleep   |  210 |           | NULL                                         |  | 769390 | testuser | localhost | testdb | Query   |    0 | executing | select * from information_schema.processlist |  +--------+----------+-----------+--------+---------+------+-----------+----------------------------------------------+ 2 rowsinset (0.00 sec)  # 授予了PROCESS权限后,站群服务器可以看到所有用户的b2b供应网杀掉链接  mysql> grant process on *.* totestuser@%;  Query OK, 0 rows affected (0.01 sec)  mysql> flush privileges;  Query OK, 0 rows affected (0.00 sec)  mysql> show grants;  +----------------------------------------------------------------------+ | Grants for testuser@%                                                |  +----------------------------------------------------------------------+ | GRANT PROCESS ON *.* TOtestuser@%                               |  | GRANTSELECT, INSERT, UPDATE, DELETEON `testdb`.* TOtestuser@% |  +----------------------------------------------------------------------+ 2 rowsinset (0.00 sec)  mysql> show processlist;  +--------+----------+--------------------+--------+---------+------+----------+------------------+ | Id     | User     | Host               | db     | Command | Time | State    | Info             |  +--------+----------+--------------------+--------+---------+------+----------+------------------+ | 769347 | root     | localhost          | testdb | Sleep   |   53 |          | NULL             |  | 769357 | root     | 192.168.85.0:61709 | NULL   | Sleep   |  521 |          | NULL             |  | 769386 | testuser | localhost          | NULL   | Sleep   |  406 |          | NULL             |  | 769473 | testuser | localhost          | testdb | Query   |    0 | starting | show processlist |  +--------+----------+--------------------+--------+---------+------+----------+------------------+ 4 rowsinset (0.00 sec)  1.2.3.4.5.6.7.8.9.10.11.12.13.14.15.16.17.18.19.20.21.22.23.24.25.26.27.28.29.30.31.32.33.34.35.36.37.38.39.40.41.42.43.44.45.46.47.48.49.50.51.52.53.54.55.56.57.58.59.60.61.62.源码库