pt-show-grants的用法

1、先查找所有用户和Host
2、然后逐个执行show grants

pt-show-grants的功能是格式化打印输出MySQL上的赋权,以便你可以有效地复制、比较以及版本控制。

[mysql@db130 ~]$ pt-show-grants --user=root --host=localhost --port=3306 --socket=/data/mysql/percona_server/run/mysql.sock --password="xxx"  --charset=utf8mb4
-- Grants dumped by pt-show-grants
-- Dumped from server Localhost via UNIX socket, MySQL 5.6.41-84.1-log at 2019-03-27 14:51:02
-- Grants for 'root'@'127.0.0.1'
GRANT ALL PRIVILEGES ON *.* TO 'root'@'127.0.0.1' IDENTIFIED BY PASSWORD '*B9C917EC2C16F9047157E4F6A12E158E5D5B86B2' WITH GRANT OPTION;
-- Grants for 'root'@'localhost'
GRANT ALL PRIVILEGES ON *.* TO 'root'@'localhost' IDENTIFIED BY PASSWORD '*B9C917EC2C16F9047157E4F6A12E158E5D5B86B2' WITH GRANT OPTION;
GRANT PROXY ON ''@'' TO 'root'@'localhost' WITH GRANT OPTION; # 增加 --drop参数
[mysql@db130 ~]$ pt-show-grants --user=root --host=localhost --port=3306 --socket=/data/mysql/percona_server/run/mysql.sock --password="xxx" --drop
-- Grants dumped by pt-show-grants
-- Dumped from server Localhost via UNIX socket, MySQL 5.6.41-84.1-log at 2019-03-27 14:48:12
DROP USER 'root'@'127.0.0.1';
DELETE FROM `mysql`.`user` WHERE `User`='root' AND `Host`='127.0.0.1';
-- Grants for 'root'@'127.0.0.1'
GRANT ALL PRIVILEGES ON *.* TO 'root'@'127.0.0.1' IDENTIFIED BY PASSWORD '*B9C917EC2C16F9047157E4F6A12E158E5D5B86B2' WITH GRANT OPTION;
DROP USER 'root'@'localhost';
DELETE FROM `mysql`.`user` WHERE `User`='root' AND `Host`='localhost';
-- Grants for 'root'@'localhost'
GRANT ALL PRIVILEGES ON *.* TO 'root'@'localhost' IDENTIFIED BY PASSWORD '*B9C917EC2C16F9047157E4F6A12E158E5D5B86B2' WITH GRANT OPTION;
GRANT PROXY ON ''@'' TO 'root'@'localhost' WITH GRANT OPTION;
[mysql@db130 ~]$
[mysql@db130 ~]$ pt-show-grants --help
pt-show-grants shows grants (user privileges) from a MySQL server. For more
details, please use the --help option, or try 'perldoc
/usr/local/bin/pt-show-grants' for complete documentation. Usage: pt-show-grants [OPTIONS] [DSN] Options: --ask-pass Prompt for a password when connecting to MySQL
--charset=s -A Default character set
--config=A Read this comma-separated list of config files; if
specified, this must be the first option on the command
line
--database=s -D The database to use for the connection
--defaults-file=s -F Only read mysql options from the given file
--drop Add DROP USER before each user in the output
--flush Add FLUSH PRIVILEGES after output
--[no]header Print dump header (default yes)
--help Show help and exit
--host=s -h Connect to host
--ignore=a Ignore this comma-separated list of users
--only=a Only show grants for this comma-separated list of users
--password=s -p Password to use when connecting
--pid=s Create the given PID file
--port=i -P Port number to use for connection
--revoke Add REVOKE statements for each GRANT statement
--separate List each GRANT or REVOKE separately
--set-vars=A Set the MySQL variables in this comma-separated list of
variable=value pairs
--socket=s -S Socket file to use for connection
--[no]timestamp Add timestamp to the dump header (default yes)
--user=s -u User for login if not current user
--version Show version and exit Option types: s=string, i=integer, f=float, h/H/a/A=comma-separated list, d=DSN, z=size, m=time Rules: This tool accepts additional command-line arguments. Refer to the SYNOPSIS and usage information for details. DSN syntax is key=value[,key=value...] Allowable DSN keys: KEY COPY MEANING
=== ==== =============================================
A yes Default character set
D yes Default database
F yes Only read default options from the given file
P yes Port number to use for connection
S yes Socket file to use for connection
h yes Connect to host
p yes Password to use when connecting
u yes User for login if not current user If the DSN is a bareword, the word is treated as the 'h' key. Options and values after processing arguments: --ask-pass FALSE
--charset (No value)
--config /etc/percona-toolkit/percona-toolkit.conf,/etc/percona-toolkit/pt-show-grants.conf,/data/mysql/.percona-toolkit.conf,/data/mysql/.pt-show-grants.conf
--database (No value)
--defaults-file (No value)
--drop FALSE
--flush FALSE
--header TRUE
--help TRUE
--host (No value)
--ignore (No value)
--only (No value)
--password (No value)
--pid (No value)
--port (No value)
--revoke FALSE
--separate FALSE
--set-vars
--socket (No value)
--timestamp TRUE
--user (No value)
--version FALSE
[mysql@db130 ~]$

pt-show-grants的用法的更多相关文章

  1. 百度地图Api进阶教程-点聚合9.html

    <!DOCTYPE html> <html> <head> <meta http-equiv="Content-Type" content ...

  2. C#开源定时回调库PETimer的使用

    PETimer PETimer开源项目GitHub地址:点击跳转 PETimer 1.双端通用:基于C#语言实现的高效便捷计时器,可运行在服务器(.net core/.net framework)以及 ...

  3. 百度地图api-动态添加覆盖物

    <!DOCTYPE html> <html> <head> <meta http-equiv="Content-Type" content ...

  4. css中字体单位px,pt,em,百分比之间的区别和用法

    px 即像素,一般国内网站使用较多,默认大小是16px; pt 印刷行业常用单位 em  相对单位,相对父元素属性的单位 ,一般用于移动端布局 rem  结合相对定位和绝对定位的优势,相对根元素htm ...

  5. mysql瑞士军刀–pt工具

    Percona-Toolkits Percona-toolkit 简介 percona-toolkit是一组高级命令行工具的集合,用来执行各种通过手工执行非常复杂和麻烦的mysql任务和系统任务,这些 ...

  6. C++中const 的各种用法

    C++中const 关键字的用法 const修饰变量 const 主要用于把一个对象转换成一个常量,例如: ; size = ; // error: assignment of read-only v ...

  7. Tcpdump的详细用法

    1. TCPDump介绍 TcpDump可以将网络中传送的数据包的"头"完全截获下来提供分析.它支持针对网络层.协议.主机.网络或端口的过滤,并提供and.or.not等逻辑语句来 ...

  8. 必备:常用px,pt,em换算表(转)

    常用px,pt,em换算表 pt (point,磅):是一个物理长度单位,指的是72分之一英寸. px (pixel,像素):是一个虚拟长度单位,是计算机系统的数字化图像长度单位,如果px要换算成物理 ...

  9. SQL LOADER 的用法 TXT文件导入非常之快

    前提,需要本地安装ORACLE 客户端 控制文件 cms.ctl load dataCHARACTERSET UTF8infile 'oracle.txt'APPEND INTO TABLE JR f ...

  10. px,pt,em,rem

    一直对px,pt,em,rem的认识有误区,现整理一下,供参考.之后还得整理下关于dpi相关的知识. px(pixe,像素l):是一个虚拟长度单位,是计算机系统的数字化图像长度单位,如果px要换算成物 ...

随机推荐

  1. Dynamics 365-关于Activity定制的一个细节

    有一个需求,是Lead上的activity创建的时候,更新regarding Entity上的某个字段信息.需求很简单,写个plugin,注册到对应activity的create事件上,Over... ...

  2. vs code配置flutter开发android

    下载flutter_sdk压缩包,解压到指定目录,把sdk的bin目录添加到系统环境变量Path 设置中国临时镜像:添加两个系统变量 FLUTTER_STORAGE_BASE_URL=https:// ...

  3. 通过maven profile 打包指定环境配置

    背景 最近换了个新公司接手了一个老项目,然后比较坑的是这个公司的项目都没有没有做多环境打包配置,每次发布一个环境都要手动的去修改配置文件.今天正好有空就来配置下. 解决这个问题的方式有很多,我这里挑选 ...

  4. git错误--ssh: Could not resolve hostname ssh.github.com: Name or service not known--解决方式

    错误如下: git push origin ssh: Could not resolve hostname ssh.github.com: Name or service not known fata ...

  5. 重庆3Shape CAMbridge都有哪些功能

    三维打印技术创新领导者Objet Geometries公司和牙科领域三维扫描仪.CAD/CAM软件解决方案供应商3Shape A/S公司日前宣布两家公司合作研发的牙科领域三维修复解决方案已付诸实施.此 ...

  6. 简单的纯js三级联动

    参考这个  日尼禾尔  二级联动 写了三级联动 <!DOCTYPE html> <html> <head> <meta charset="UTF-8 ...

  7. EOS开发环境搭建

    EOS开发环境搭建   在上一篇文章<扒一扒EOS的前世今生>中,我们已经了解了EOS以及他的创始人Daniel Larimer的故事,本次为大家带来的是关于EOS开发环境搭建的内容.首先 ...

  8. 【转】Dockerfile详解

    Dockerfile详解 https://blog.csdn.net/wo18237095579/article/details/80540571 --------------------- 作者:大 ...

  9. 《重构》的读书笔记–方法列表

    第5章 重构列表 5.1 重构的记录格式103 5.2 寻找引用点105 5.3 这些重构手法有多成熟106 第6章 重新组织函数 6.1 (P110)Extract Method(提炼函数) 6.2 ...

  10. ASP.NET MVC 自定义模型绑定1 - 自动把以英文逗号分隔的 ID 字符串绑定成 List<int>

    直接贴代码了: CommaSeparatedModelBinder.cs using System; using System.Collections; using System.Collection ...