查看mysql全部用户的权限

下午有安全检查,须要我告诉检查人员数据库中全部用户的权限,百度以后,记录下查询方法作记录,首先查询出数据库里全部的用户:
python

  1. mysql> select distinct concat(user ,'@',host) as query from mysql.user \G;
    mysql

  2. *************************** 1. row ***************************
    sql

  3. query: root@127.0.0.1
    数据库

  4. *************************** 2. row ***************************
    安全

  5. query: root@::1
    dom

  6. *************************** 3. row ***************************
    ide

  7. query: python@local
    url

  8. *************************** 4. row ***************************
    spa

  9. query: python@localhost
    code

  10. *************************** 5. row ***************************

  11. query: qhz@localhost

  12. *************************** 6. row ***************************

  13. query: root@localhost

  14. *************************** 7. row ***************************

  15. query: zabbix@localhost

  16. *************************** 8. row ***************************

  17. query: root@localhost.localdomain

  18. 8 rows in set (0.00 sec)


  19. ERROR:

  20. No query specified


  21. mysql> select distinct concat(user ,'@',host) as query from mysql.user ;

  22. +----------------------------+

  23. | query                      |

  24. +----------------------------+

  25. | root@127.0.0.1             |

  26. | root@::1                   |

  27. | python@local               |

  28. | python@localhost           |

  29. | qhz@localhost              |

  30. | root@localhost             |

  31. | zabbix@localhost           |

  32. | root@localhost.localdomain |

  33. +----------------------------+

  34. 8 rows in set (0.00 sec)


复制代码
上面内容都是查询到的用户,而后你须要看那个用户的权限,分别来查询下他们的权限,好比咱们看看zabbix的权限:
  1. mysql> show grants for zabbix@localhost;

  2. +------------------------------------------------------------------------------------------------------------------------+

  3. | Grants for zabbix@localhost                                                                                            |

  4. +------------------------------------------------------------------------------------------------------------------------+

  5. | GRANT ALL PRIVILEGES ON *.* TO 'zabbix'@'localhost' IDENTIFIED BY PASSWORD '*6BB4837EB74329105EE4568DDA7DC67ED2CA2AD9' |

  6. | GRANT ALL PRIVILEGES ON `zabbix`.* TO 'zabbix'@'localhost'                                                             |

  7. +------------------------------------------------------------------------------------------------------------------------+

  8. 2 rows in set (0.00 sec)


复制代码
上面显示的内容就是咱们查询到的zabbix在本机的权限
加入你想看其余的用户的权限,能够换其余用户便可
相关文章
相关标签/搜索