Skip to content



pt-config-diff - Diff MySQL configuration files and server variables.



pt-config-diff [OPTIONS] CONFIG CONFIG [CONFIG...]

pt-config-diff diffs MySQL configuration files and server variables. CONFIG can be a filename or a DSN. At least two CONFIG sources must be given. Like standard Unix diff, there is no output if there are no differences.

Diff host1 config from SHOW VARIABLES against host2:

pt-config-diff h=host1 h=host2

Diff config from [mysqld] section in my.cnf against host1 config:

pt-config-diff /etc/my.cnf h=host1

Diff the [mysqld] section of two option files:

pt-config-diff /etc/my-small.cnf /etc/my-large.cnf


Percona Toolkit is mature, proven in the real world, and well tested, but all database tools can pose a risk to the system and the database server. Before using this tool, please:

  • Read the tool’s documentation

  • Review the tool’s known “BUGS”

  • Test the tool on a non-production server

  • Backup your production server and verify the backups


pt-config-diff diffs MySQL configurations by examining the values of server system variables from two or more CONFIG sources specified on the command line. A CONFIG source can be a DSN or a filename containing the output of mysqld --help --verbose, my_print_defaults, SHOW VARIABLES, or an option file (e.g. my.cnf).

For each DSN CONFIG, pt-config-diff connects to MySQL and gets variables and values by executing SHOW /*!40103 GLOBAL*/ VARIABLES. This is an “active config” because it shows what server values MySQL is actively (currently) running with.

Only variables that all CONFIG sources have are compared because if a variable is not present then we cannot know or safely guess its value. For example, if you compare an option file (e.g. my.cnf) to an active config (i.e. SHOW VARIABLES from a DSN CONFIG), the option file will probably only have a few variables, whereas the active config has every variable. Only values of the variables present in both configs are compared.

Option file and DSN configs provide the best results.


There is no output when there are no differences. When there are differences, pt-config-diff prints a report to STDOUT that looks similar to the following:

2 config differences
Variable                  my.master.cnf   my.slave.cnf
========================= =============== ===============
datadir                   /tmp/12345/data /tmp/12346/data
port                      12345           12346

Comparing MySQL variables is difficult because there are many variations and subtleties across the many versions and distributions of MySQL. When a comparison fails, the tool prints a warning to STDERR, such as the following:

Comparing log_error values (mysqld.log, /tmp/12345/data/mysqld.log)
caused an error: Argument "/tmp/12345/data/mysqld.log" isn't numeric
in numeric eq (==) at ./pt-config-diff line 2311.

Please report these warnings so the comparison functions can be improved.


pt-config-diff exits with a zero exit status when there are no differences, and 1 if there are.


This tool accepts additional command-line arguments. Refer to the “SYNOPSIS” and usage information for details.


Prompt for a password when connecting to MySQL.


short form: -A; type: string

Default character set. If the value is utf8, 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.


type: Array

Read this comma-separated list of config files; if specified, this must be the first option on the command line. (This option does not specify a CONFIG; it’s equivalent to --defaults-file.)


short form: -D; type: string

Connect to this database.


short form: -F; type: string

Only read mysql options from the given file. You must give an absolute pathname.


Show help and exit.


short form: -h; type: string

Connect to host.


default: yes

Compare the variables case-insensitively.


type: array

Ignore, do not compare, these variables.


short form: -p; type: string

Password to use for connection.


type: string

Create the given PID file. The tool won’t start if the PID file already exists and the PID it contains is different than the current PID. However, if the PID file exists and the PID it contains is no longer running, the tool will overwrite the PID file with the current PID. The PID file is removed automatically when the tool exits.


short form: -P; type: int

Port number to use for connection.


default: yes

Print the MySQL config diff report to STDOUT. If you just want to check if the given configs are different or not by examining the tool’s exit status, then specify --no-report to suppress the report.


type: int; default: 78

Truncate report lines to this many characters. Since some variable values can be long, or when comparing multiple configs, it may help to increase the report width so values are not truncated beyond readability.


type: Array

Set the MySQL variables in this comma-separated list of variable=value pairs.

By default, the tool sets:


Variables specified on the command line override these defaults. For example, specifying --set-vars wait_timeout=500 overrides the defaultvalue of 10000.

The tool prints a warning and continues if a variable cannot be set.


short form: -S; type: string

Socket file to use for connection.


short form: -u; type: string

MySQL user if not current user.


Show version and exit.


default: yes

Check for the latest version of Percona Toolkit, MySQL, and other programs.

This is a standard “check for updates automatically” feature, with two additional features. First, the tool checks its own version and also the versions of the following software: operating system, Percona Monitoring and Management (PMM), MySQL, Perl, MySQL driver for Perl (DBD::mysql), and Percona Toolkit. Second, it checks for and warns about versions with known problems. For example, MySQL 5.5.25 had a critical bug and was re-released as 5.5.25a.

A secure connection to Percona’s Version Check database server is done to perform these checks. Each request is logged by the server, including software version numbers and unique ID of the checked system. The ID is generated by the Percona Toolkit installation script or when the Version Check database call is done for the first time.

Any updates or known problems are printed to STDOUT before the tool’s normal output. This feature should never interfere with the normal operation of the tool.

For more information, visit


These DSN options are used to create a DSN. Each option is given like option=value. The options are case-sensitive, so P and p are not the same option. There cannot be whitespace before or after the = and if the value contains whitespace it must be quoted. DSN options are comma-separated. See the percona-toolkit manpage for full details.

  • A

dsn: charset; copy: yes

Default character set.

  • D

dsn: database; copy: yes

Default database.

  • F

dsn: mysql_read_default_file; copy: yes

Only read default options from the given file

  • h

dsn: host; copy: yes

Connect to host.

  • p

dsn: password; copy: yes

Password to use when connecting. If password contains commas they must be escaped with a backslash: “exam,ple”

  • P

dsn: port; copy: yes

Port number to use for connection.

  • S

dsn: mysql_socket; copy: yes

Socket file to use for connection.

  • u

dsn: user; copy: yes

User for login if not current user.


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-config-diff ... > FILE 2>&1

Be careful: debugging output is voluminous and can generate several megabytes of output.


Using <PTDEBUG> might expose passwords. When debug is enabled, all command line parameters are shown in the output.


You need Perl, DBI, DBD::mysql, and some core packages that ought to be installed in any reasonably new version of Perl.


For a list of known bugs, see

Please report bugs at Include the following information in your bug report:

  • Complete command-line used to run the tool

  • Tool --version

  • MySQL 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”.


Visit to download the latest release of Percona Toolkit. Or, get the latest release from the command line:




You can also get individual tools from the latest release:


Replace TOOL with the name of any tool.


Baron Schwartz and Daniel Nichter


This tool is part of Percona Toolkit, a collection of advanced command-line tools for MySQL developed by Percona. Percona Toolkit was forked from two projects in June, 2011: Maatkit and Aspersa. Those projects were created by Baron Schwartz and primarily developed by him and Daniel Nichter. Visit to learn about other free, open-source software from Percona.


pt-config-diff 3.5.7