The main function of this tool is to be able to print authorization related information , It is convenient to compare the differences MySQL Are database permissions the same , With this tool, we can easily copy users from one server to another , You can simply extract authorization from the first server , And import the output pipeline directly to another server , You can also do permission version control :
Basically, it has the above functions , Specific use can be tested , Now let's take a look at the basic use as follows : [[email protected] bin]# ./pt-show-grants
--host=172.16.16.35 --port=3306 --user=root --password=123456 -- Grants dumped
by pt-show-grants -- Dumped from server 172.16.16.35 via TCP/IP, MySQL 5.7.14
-log at2017-06-26 14:59:53 -- Grants for 'dev_01334938'@'%' CREATE USER IF NOT
EXISTS'dev_01334938'@'%'; ALTER USER 'dev_01334938'@'%' IDENTIFIED WITH '
mysql_native_password' AS '*6BB4837EB74329105EE4568DDA7DC67ED2CA2AD9' REQUIRE
NONE PASSWORD EXPIRE DEFAULT ACCOUNT UNLOCK; GRANT SELECT ON `gshop_db`.* TO '
dev_01334938'@'%'; GRANT USAGE ON *.* TO 'dev_01334938'@'%'; -- Grants for '
mysql.sys'@'localhost' CREATE USER IF NOT EXISTS 'mysql.sys'@'localhost'; ALTER
USER'mysql.sys'@'localhost' IDENTIFIED WITH 'mysql_native_password' AS '
*THISISNOTAVALIDPASSWORDTHATCANBEUSEDHERE' REQUIRE NONE PASSWORD EXPIRE DEFAULT
ACCOUNT LOCK; GRANT SELECT ON `sys`.`sys_config` TO'mysql.sys'@'localhost';
GRANT TRIGGER ON `sys`.* TO 'mysql.sys'@'localhost'; GRANT USAGE ON *.* TO '
mysql.sys'@'localhost'; -- Grants for 'repl'@'172.16.16.%' CREATE USER IF NOT
EXISTS'repl'@'172.16.16.%'; ALTER USER 'repl'@'172.16.16.%' IDENTIFIED WITH '
mysql_native_password' AS '*D36660B5249B066D7AC5A1A14CECB71D36944CBC' REQUIRE
NONE PASSWORD EXPIRE DEFAULT ACCOUNT UNLOCK; GRANT REPLICATION CLIENT,
REPLICATION SLAVE ON*.* TO 'repl'@'172.16.16.%'; -- Grants for 'replication'@'
10.102.2.%' CREATE USER IF NOT EXISTS 'replication'@'10.102.2.%'; ALTER USER '
replication'@'10.102.2.%' IDENTIFIED WITH 'mysql_native_password' AS '
*6BB4837EB74329105EE4568DDA7DC67ED2CA2AD9' REQUIRE NONE PASSWORD EXPIRE DEFAULT
ACCOUNT UNLOCK; GRANT USAGE ON*.* TO 'replication'@'10.102.2.%'; -- Grants for '
replication'@'10.102.4.%' CREATE USER IF NOT EXISTS 'replication'@'10.102.4.%';
ALTER USER'replication'@'10.102.4.%' IDENTIFIED WITH 'mysql_native_password'
REQUIRE NONE PASSWORD EXPIRE DEFAULT ACCOUNT UNLOCK; GRANT SELECT ON `gshop_db`.
* TO'replication'@'10.102.4.%'; GRANT USAGE ON *.* TO 'replication'@'10.102.4.%'
;-- Grants for 'root'@'%' CREATE USER IF NOT EXISTS 'root'@'%'; ALTER USER 'root
'@'%' IDENTIFIED WITH 'mysql_native_password' AS '
*6BB4837EB74329105EE4568DDA7DC67ED2CA2AD9' REQUIRE NONE PASSWORD EXPIRE DEFAULT
ACCOUNT UNLOCK; GRANT ALL PRIVILEGES ON*.* TO 'root'@'%' WITH GRANT OPTION; --
Grantsfor 'root'@'localhost' CREATE USER IF NOT EXISTS 'root'@'localhost';
ALTER USER'root'@'localhost' IDENTIFIED WITH 'mysql_native_password' AS '
*6BB4837EB74329105EE4568DDA7DC67ED2CA2AD9' REQUIRE NONE PASSWORD EXPIRE DEFAULT
ACCOUNT UNLOCK; GRANT ALL PRIVILEGES ON*.* TO 'root'@'localhost' WITH GRANT
OPTION; GRANT PROXY ON''@'' TO 'root'@'localhost' WITH GRANT OPTION;