PERCONA-TOOLKIT(1)

๐Ÿ’… PERCONA-TOOLKIT(1) โœจ

๐ŸŽ€ NAME

percona-toolkit โ€” Advanced command-line tools for MySQL ๐Ÿซถ

๐ŸŒธ DESCRIPTION

Okay so bestie, Percona Toolkit is a whole collection of advanced command-line tools used by Percona support staff (<http://www.percona.com/>) to do a bunch of MySQL and system tasks that are honestly too difficult or complex to do by hand. No cap. ๐Ÿ˜ญ

These tools are ideal alternatives to private or โ€œone-offโ€ scripts because they are professionally developed, formally tested, and fully documented. They are also fully self-contained, so installation is quick and easy and no libraries are installed. Itโ€™s giving polished, lowkey iconic, and highkey practical. โœจ

Percona Toolkit is derived from Maatkit and Aspersa, two of the best-known toolkits for MySQL server administration. It is developed and supported by Percona. For more information and other free, open-source software developed by Percona, visit <http://www.percona.com/software/>. ๐Ÿ’–

๐Ÿ‘‘ TOOLS

This release of Percona Toolkit includes the following tools:

  • pt-align โ€” Align output from other tools to columns.
  • pt-archiver โ€” Archive rows from a MySQL table into another table or a file.
  • pt-config-diff โ€” Diff MySQL configuration files and server variables.
  • pt-deadlock-logger โ€” Log MySQL deadlocks.
  • pt-diskstats โ€” An interactive I/O monitoring tool for GNU/Linux.
  • pt-duplicate-key-checker โ€” Find duplicate indexes and foreign keys on MySQL tables.
  • pt-eustack-resolver โ€” Get stack traces for a selected program with eu-stack and resolve symbols.
  • pt-fifo-split โ€” Split files and pipe lines to a fifo without really splitting.
  • pt-find โ€” Find MySQL tables and execute actions, like GNU find.
  • pt-fingerprint โ€” Convert queries into fingerprints.
  • pt-fk-error-logger โ€” Log MySQL foreign key errors.
  • pt-galera-log-explainer โ€” Filter, aggregate and summarize multiple galera logs together.
  • pt-heartbeat โ€” Monitor MySQL replication delay.
  • pt-index-usage โ€” Read queries from a log and analyze how they use indexes.
  • pt-ioprofile โ€” Watch process IO and print a table of file and I/O activity.
  • pt-k8s-debug-collector โ€” Collect debug data from a k8s/OpenShift cluster.
  • pt-kill โ€” Kill MySQL queries that match certain criteria.
  • pt-mext โ€” Look at many samples of MySQL SHOW GLOBAL STATUS side-by-side.
  • pt-mongodb-index-check โ€” Performs checks on MongoDB indexes.
  • pt-mongodb-query-digest โ€” Reports query usage statistics by aggregating queries from MongoDB query profiler.
  • pt-mongodb-summary โ€” Collect information about a MongoDB cluster.
  • pt-mysql-summary โ€” Summarize MySQL information nicely.
  • pt-online-schema-change โ€” ALTER tables without locking them.
  • pt-pg-summary โ€” Collect information about a PostgreSQL cluster.
  • pt-pmp โ€” Aggregate GDB stack traces for a selected program.
  • pt-query-digest โ€” Analyze MySQL queries from logs, processlist, and tcpdump.
  • pt-secure-collect โ€” Collect, sanitize, pack and encrypt data.
  • pt-show-grants โ€” Canonicalize and print MySQL grants so you can effectively replicate, compare and version-control them.
  • pt-sift โ€” Browses files created by pt-stalk.
  • pt-slave-delay โ€” Make a MySQL slave server lag behind its master.
  • pt-slave-find โ€” Find and print replication hierarchy tree of MySQL slaves.
  • pt-slave-restart โ€” Watch and restart MySQL replication after errors.
  • pt-stalk โ€” Collect forensic data about MySQL when problems occur.
  • pt-summary โ€” Summarize system information nicely.
  • pt-table-checksum โ€” Verify MySQL replication integrity.
  • pt-table-sync โ€” Synchronize MySQL table data efficiently.
  • pt-table-usage โ€” Analyze how queries use tables.
  • pt-upgrade โ€” Verify that query results are identical on different servers.
  • pt-variable-advisor โ€” Analyze MySQL variables and advise on possible problems.
  • pt-visual-explain โ€” Format EXPLAIN output as a tree.

For more free, open-source software developed by Percona, visit <http://www.percona.com/software/>. ๐ŸŒˆ

๐Ÿ”ฎ SPECIAL OPTION TYPES

Tool options use standard types (int, string, etc.) as well as these special types:

  • time โ€” Time values are seconds by default. For example, --run-time 60 means 60 seconds. Time values support an optional suffix: s (seconds), m (minutes), h (hours), d (days). --run-time 1m means 1 minute (the same as 60 seconds). โฐ
  • size โ€” Size values are bytes by default. For example, --disk-space-free 1024 means 1 Kibibyte. Size values support an optional suffix: k (Kibibyte), M (Mebibyte), G (Gibibyte). ๐Ÿ“
  • DSN โ€” See โ€œDSN (DATA SOURCE NAME) SPECIFICATIONSโ€.
  • Hash, hash, Array, array โ€” Hash, hash, Array, and array values are comma-separated lists of values. For example, --ignore-tables foo,bar ignores tables foo and bar.

๐Ÿ—‚๏ธ CONFIGURATION FILES

Percona Toolkit tools can read options from configuration files. The configuration file syntax is simple and direct, and bears some resemblances to the MySQL command-line client tools. The configuration files all follow the same conventions. ๐Ÿ’…

Internally, what actually happens is that the lines are read from the file and then added as command-line options and arguments to the tool, so just think of the configuration files as a way to write your command lines. Itโ€™s literally command-line energy, but stored in a file. โœจ

๐ŸŒธ SYNTAX

The syntax of the configuration files is as follows:

  • Whitespace followed by a hash sign (#) signifies that the rest of the line is a comment. This is deleted. For example:
  • Whitespace is stripped from the beginning and end of all lines.
  • Empty lines are ignored.
  • Each line is permitted to be in either of the following formats:
option
option=value

Do not prefix the option with --. Do not quote the values, even if it has spaces; values are literal. Whitespace around the equals sign is deleted during processing.

  • Only long options are recognized.
  • A line containing only two hyphens (--) signals the end of option parsing. Any further lines are interpreted as additional arguments (not options) to the program.

๐Ÿงช EXAMPLE

This config file for pt-stalk,

# Config for pt-stalk
variable=Threads_connected
cycles=2  # trigger if problem seen twice in a row
--
--user daniel

is equivalent to this command line:

pt-stalk --variable Threads_connected --cycles 2 -- --user daniel

Options after -- are passed literally to mysql and mysqladmin. ๐Ÿซถ

๐Ÿ“š READ ORDER

The tools read several configuration files in order:

  1. The global Percona Toolkit configuration file, /etc/percona-toolkit/percona-toolkit.conf. All tools read this file, so you should only add options to it that you want to apply to all tools.
  2. The global tool-specific configuration file, /etc/percona-toolkit/TOOL.conf, where TOOL is a tool name like pt-query-digest. This file is named after the specific tool youโ€™re using, so you can add options that apply only to that tool.
  3. The userโ€™s own Percona Toolkit configuration file, $HOME/.percona-toolkit.conf. All tools read this file, so you should only add options to it that you want to apply to all tools.
  4. The userโ€™s tool-specific configuration file, $HOME/.TOOL.conf, where TOOL is a tool name like pt-query-digest. This file is named after the specific tool youโ€™re using, so you can add options that apply only to that tool. ๐Ÿ‘‘

๐ŸŽฏ SPECIFYING

There is a special --config option, which lets you specify which configuration files Percona Toolkit should read. You specify a comma-separated list of files. However, its behavior is not like other command-line options. It must be given first on the command line, before any other options. If you try to specify it anywhere else, it will cause an error. Also, you cannot specify --config=/path/to/file; you must specify the option and the path to the file separated by whitespace without an equal sign between them, like:

--config /path/to/file

If you donโ€™t want any configuration files at all, specify --config '' to provide an empty list of files. ๐Ÿ™ˆ

๐Ÿ’… DSN (DATA SOURCE NAME) SPECIFICATIONS ๐ŸŽ€

okay so this is the part where we talk about DSNs, and bestie, they're literally the whole personality of Percona Toolkit tools โ€” they tell a tool how to build a DBD connection to a MySQL server. A DSN is just a comma-separated string of key=value parts, like:

h=host1,P=3306,u=bob

The standard key parts are listed down below, but some tools add extra ones for the plot, so check each tool's docs for those. iykyk.

Some tools don't do DSNs at all and still connect to MySQL using options like --host, --user, and --password. Those tools take those options and create a DSN automatically behind the scenes. sneaky but cute.

Other tools use both DSNs and options like the ones up there. In that case the options are basically giving defaults to every DSN that doesn't specify that option's corresponding key part. Example: if DSN is h=host1 and you also pass --port=12345, the tool automatically adds P=12345 to the DSN. teamwork!


๐Ÿ” ESCAPING VALUES โœจ

DSNs usually get typed on the command line, so shell quoting and escaping are absolutely part of the vibe check. Special characters like the asterisk (*) need to be quoted and/or escaped properly if you want them to come through as literal characters in DSN values.

And here's the tricky part โ€” since DSN parts are separated by commas, literal commas inside DSN values must be escaped with a single backslash (\). But because a backslash is the escape character for most shells, you need two backslashes to actually pass a literal backslash. So if your username is literally my,name, on most shells you have to write it as my\\,name. This applies to DSNs and to DSN-related options like --user. no cap, write it down.


๐Ÿ”‘ KEY PARTS ๐Ÿ’–

Many tools add more parts to DSNs for special purposes, and sometimes they override parts so they do something slightly different. But all the tools support at least these:

  • A โ€” default character set for the connection (SET NAMES). This turns on character set settings in both Perl and MySQL. If the value is utf8, it sets Perl's binmode on STDOUT to utf8, passes the mysql_enable_utf8 option to DBD::mysql, and runs SET NAMES 'utf8' after connecting to MySQL. Any other value sets binmode on STDOUT without the utf8 layer and runs SET NAMES after connecting to MySQL. Sad part: there's genuinely no way from inside Perl itself to specify the client library's character set ๐Ÿ˜ญ SET NAMES only affects the server, so if the client library's settings don't match, problems can happen. You can use the defaults file to specify the client library's character set though โ€” see the F part below.
  • D โ€” default database to use when connecting. Tools may USE a different database while running, so don't get too attached.
  • F โ€” defaults file for the MySQL client library (that's the C client library used by DBD::mysql, not Percona Toolkit itself). All tools read the [client] section within the defaults file. If you omit this, the standard defaults files get read in the usual order. "Standard" varies from system to system because the filenames to read are compiled into the client library. On Debian systems, for example, it's usually /etc/mysql/my.cnf then ~/.my.cnf. If you drop this into ~/.my.cnf, you won't have to type your MySQL username and password on the command line:
[client]
user=your_user_name
pass=secret

Omitting the F part is usually the right thing to do. As long as you've configured your ~/.my.cnf correctly, the tools will connect automatically without needing a username or password. slay.

You can also specify a default character set in the defaults file. Unlike the A part above, this actually instructs the client library (DBD::mysql) to change the character set it uses internally โ€” and there's no other way to accomplish that. icon behavior only.

  • h โ€” MySQL hostname or IP address to connect to.
  • L โ€” explicitly enable LOAD DATA LOCAL INFILE. For some reason, some vendors compile libmysql without the --enable-local-infile option, which disables the statement. That leads to truly cursed situations, like the server allowing LOCAL INFILE but the client throwing exceptions when it's used ๐Ÿ’€ The good news: as long as the server allows LOAD DATA, clients can easily re-enable it. See https://dev.mysql.com/doc/refman/en/load-data-local-security.html and http://search.cpan.org/~capttofu/DBD-mysql/lib/DBD/mysql.pm. This option does exactly that.
  • p โ€” MySQL password to use when connecting.
  • P โ€” port number to use for the connection. Note the usual special-case behaviors apply: if you specify localhost as your hostname on Unix systems, the connection actually uses a socket file, not a TCP/IP connection, and therefore ignores the port. rude but consistent.
  • S โ€” MySQL socket file to use for the connection (on Unix systems).
  • u โ€” MySQL username to use when connecting, if not the current system user.
  • s โ€” create SSL connection ๐Ÿ”’

๐Ÿ—ฃ๏ธ BAREWORD ๐ŸŒธ

Many tools let you specify a DSN as a single word, with zero key=value syntax. That's called a 'bareword'. How it's handled is tool-specific, but it's usually interpreted as the h part. The tool's --help output will tell you the behavior for that specific tool. main character energy, honestly.


๐Ÿซถ PROPAGATION ๐Ÿฆ‹

Many tools let you propagate values from one DSN to the next so you don't have to spell out every part of every DSN. For example, if you want to specify a username and password for each DSN, you can connect to three hosts like this:

h=host1,u=fred,p=wilma host2 host3

This is tool-specific, so peek at the docs. ๐Ÿ’œ


๐ŸŒˆ ENVIRONMENT โญ

The environment variable PTDEBUG enables verbose debugging output to STDERR. To enable debugging and capture all output to a file, run the tool like:

PTDEBUG=1 pt-table-checksum ... > FILE 2>&1
โš ๏ธ Be careful: debugging output is voluminous and can generate several megabytes of output. like, gigabytes-of-vibes levels of output. hydrate and check your disk space.

๐Ÿงš SYSTEM REQUIREMENTS ๐Ÿ“

Most tools require:

  • Perl v5.8 or newer
  • Bash v3 or newer
  • Core Perl modules like Time::HiRes

Tools that connect to MySQL require:

  • Perl modules DBI and DBD::mysql
  • MySQL 5.0 or newer

Percona Toolkit officially supports and is tested on many popular Linux distributions and MySQL 5.0 through 5.6; see http://goo.gl/srHm7 for the list of supported platforms and versions.

๐ŸŒ IPv6 support ๐Ÿฆ‹

In order to support IPv6 addresses to connect to MySQL, Perl DBD::MySQL driver v4.033_01 is required. Also, as stated in RFC 3986 https://www.ietf.org/rfc/rfc3986.txt section 3.2.2, brackets must be used to distinguish host and port. Examples here: https://metacpan.org/pod/DBD::mysql#port. brackets are the moment, don't skip them.


๐Ÿ› BUGS ๐Ÿ˜ญ

Please report bugs at https://jira.percona.com. Include the following info in your bug report:

  • Complete command-line used to run the tool
  • Tool --version
  • MySQL, MongoDB, or PostgreSQL version of all servers involved
  • Output from the tool including STDERR
  • Input files (log/dump/config files, etc.)

If possible, include debugging output by running the tool with PTDEBUG; see "ENVIRONMENT" above. the maintainers will love you for it fr fr.


๐Ÿ‘‘ AUTHORS ๐Ÿ’…

  • Baron Schwartz โ€” Baron created Maatkit, from which Percona Toolkit was forked. Many of the tools and modules were originally written by Baron.
  • Daniel Nichter โ€” Daniel was the project's lead developer from 2008 until 2016.
  • Frank Cizmich โ€” Frank was a full-time Percona Toolkit developer employed by Percona until 2016.
  • Carlos Salguero โ€” Carlos was the project's lead developer from 2016 until 2022.
  • Sveta Smirnova โ€” Sveta is the project's lead developer since 2022.
  • Others โ€” many people have contributed code over the years. See each tool's AUTHORS section for details.

legends, all of them. ๐Ÿซถ


Percona Toolkit is copyright 2011-2026 Percona LLC and/or its affiliates, et al. See each program's documentation for complete copyright notices.

THIS PROGRAM IS PROVIDED "AS IS" AND WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.

This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, version 2; OR the Perl Artistic License. On UNIX and similar systems, you can issue man perlgpl or man perlartistic to read these licenses.

You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.


โญ VERSION ๐ŸŽ€

Percona Toolkit v3.7.1-4 released 2026-07-02


okay that's the whole page bestie, you made it to the end ๐ŸŽ‰ this edition came from perl v5.42.2, dated 2026-09-01, and it's the PERCONA-TOOLKIT(1) manual page โ€” go forth and connect to things responsibly ๐Ÿ’œโœจ

๐Ÿ“ฆ where this page comes from