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. 生鲜配送管理系统_升鲜宝V2.0 价格组功能 操作说明_15382353715

    价格组功能是B端供应链系统,必不可少的一个功能,其主要实现不同的客户不同的价格,B端系统有一个最大的不同就是,有些商品后台下单人员能看到的.有些商品在销售的那一瞬间,还不知道价格.所以这些商品只有后台 ...

  2. Python 标准类库 - 因特网协议与支持之socketserver

    标准类库 - 因特网协议与支持之socketserver by:授客 QQ:1033553122 socketserver 模块,简化网络服务编写任务. 创建服务的步骤 1  通过子类化BaseReq ...

  3. 共创力董事长杨学明先生受邀参加CED智慧大会!

    2018年11月14日, 深圳市共创力咨询董事长.深圳市汇成研发管理咨询公司董事长杨学明先生受邀参加由深圳图书馆主办,深圳手讯视频承办的“倾听行业之声”2018第二届世界CED智慧大会,此次分享的主题 ...

  4. DbGridEh根据某一个字段的值显示对应底色或字体变化

    改变行底色: procedure TForm1.dggrideh1DrawColumnCell(Sender: TObject;const Rect: TRect; DataCol: Integer; ...

  5. 轻松学习UML之类图,状态图

    本文主要讲解UML图中的类图与状态图相关内容,如有不足之处,还请指正. 概述 统一建模语言(UML,UnifiedModelingLanguage)是面向对象软件的标准化建模语言,UML因其简单.统一 ...

  6. git stash解决代码merge出错

    最近在使用git提交代码时,遇到一个问题,就是我修改了几个文件的代码,然后又想把自己代码库里面的代码更新到最新版本,然后不出所料,代码冲突了!作为一个喜欢解决问题的程序员,怎么会被这样的问题所困住呢? ...

  7. Java基础系列--01_基础类型

    J2SE.J2ME.J2EE分别指什么? J2SE 基础版,桌面应用. J2ME 微型版,手机开发.(android,ios) J2EE 企业版,所有浏览器访问的应用程序. 注意:JDK5以后改名 J ...

  8. 七 Struts2 文件上传和下载

    配置文件 <?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE struts PUBLIC &qu ...

  9. C#-之属性(1)

    1. 属性定义方式与字段类似,但还包括Set和Get两个访问器,其格式如下: public/private <type> Name { get { return variable:    ...

  10. mysql union 与 union all 语法及用法

    1.mysql   union  语法 mysql   union 用于把来自多个select  语句的结果组合到一个结果集合中.语法为: select  column,......from tabl ...