Pt-show-grants with user and password file

Hi all,

i would like to save all grants of a server when i do the DBs backup (it runs every night)

While mysql and mysqldump commands have an extrafile option that permit to use a file like this



that automatically pass the user/password information if using mysql (client) or nysqldump command

This is not available on pt-show-grants it has only -p option or i don’t find the right option to specify a file with credentials inside.

I know it can be a security issue put credentials on a file, but in this case i prefer to have it.

I know also that these information are on the information_schema DB that i backup every night, but it would be easier to recover from a SQL file if i need anyway.

Let me know if it is possible also with pt-show-grants command.

Thanks in advance

Hi @soprano,

Our tool pt-show-grant will be able to read the credentials from [client] section and produce to result for you.
You can thus create a backup as
pt-show-grants > backup_mysql_grants.sql


[client] section in the my.cnf ? or in another file ?

if another file how i specify it ?

Thanks in advance

in my.cnf or .my.cnf
If you want you can keep those things in variable like:

read -s pw
pt-show-grants -uUSER -p$pw > backup_mysql_grants.sql


Yes. The client section of .my.cnf or my.cnf are automatically read by all programs that use the libmysqlclient library, which is about 99% of apps that connect to MySQL. You don’t need any extra flags to get this functionality.