The mysqltest program runs a test case against a MySQL server and optionally compares the output with a result file. This program reads input written in a special test language. Typically, you invoke mysqltest using mysql-test-run.pl rather than invoking it directly.
mysqltest_embedded is similar but is built
with support for the
Features of mysqltest:
Can send SQL statements to MySQL servers for execution
Can execute external shell commands
Can test whether the result from an SQL statement or shell command is as expected
Can connect to one or more standalone mysqld servers and switch between connections
Can connect to an embedded server
libmysqld), if MySQL is compiled with
libmysqld. (In this case, the
executable is named mysqltest_embedded
rather than mysqltest.)
You can also name the test case file with a
The exit value from mysqltest is 0 for success, 1 for failure, and 62 if it skips the test case (for example, if after checking some preconditions it decides not to run the test).
mysqltest supports the following options:
Display a help message and exit.
The base directory for tests.
The directory where character sets are installed.
Compress all information sent between the client and the server if both support compression.
Use cursors for prepared statements.
The default database to use.
Write a debugging log if MySQL is built with debugging
support. The default
debug_options value is
Print some debugging information when the program exits.
Print debugging information and memory and CPU usage statistics when the program exits.
Connect to the MySQL server on the given host.
Include the contents of the given file before processing the
contents of the test file. The included file should have the
same format as other mysqltest test
files. This option has the same effect as putting a
the first line of the test file.
The directory to use for log files.
Write the line number and elapsed time to
The maximum number of connection attempts when connecting to server.
The maximum number of simultaneous server connections per client (that is, per test). If not set, the maximum is 128. Minimum allowed limit is 8, maximum is 5120.
This option is available from MySQL 5.1.45.
Do not read default options from any option files. If used, this must be the first option.
The directory in which to look for plugins. It may be
necessary to specify this option if the
default_auth argument is used for
connect() command to specify an
authentication plugin but mysqltest does
not find it. This option was added in MySQL 5.5.7.
The password to use when connecting to the server. If you
use the short option form (
cannot have a space between the option
and the password. If you omit the
password value following the
-p option on
the command line, you are prompted for one.
The TCP/IP port number to use for the connection.
Choose the protocol for communication with the server.
SOCKET is default.
--protocol option is available from
MySQL 5.1.51. It is ignored if running with the embedded
Use the prepared-statement protocol for communication.
Record the output that results from running the test file
into the file named by the
option, if that option is given. It is an error to use this
option without also using
This option specifies the file for test case expected
--result-file, together with
--record, determines how
mysqltest treats the test actual and
expected results for a test case:
If the test produces no results,
mysqltest exits with an error message
to that effect, unless
given and the named file is an empty file.
--result-file is not
given, mysqltest sends test results
to the standard output.
--result-file but not
reads the expected results from the given file and
compares them with the actual results. If the results do
not match, mysqltest writes a
.reject file in the same directory
as the result file, outputs a diff of the two files, and
exits with an error.
updates the given file by writing the actual test
results to it.
Pass the argument as an argument to the embedded server. For
--server-arg=--core. Up to 64 arguments can
Read arguments for the embedded server from the given file. The file should contain one argument per line.
The path name to a file containing the server RSA public
key. The file must be in PEM format. The public key is used
for RSA encryption of the client password for connections to
the server made using accounts that authenticate with the
sha256_password plugin. This option is
ignored for client accounts that do not authenticate with
that plugin. It is also ignored if password encryption is
not needed, as is the case when the client connects to the
server using an SSL connection.
The server sends the public key to the client as needed, so it is not necessary to use this option for RSA password encryption to occur. It is more efficient to do so because then the server need not send the key.
For additional discussion regarding use of the
sha256_password plugin, including how to
get the RSA public key, see
The SHA-256 Authentication Plugin.
This option is available only if MySQL was built using
OpenSSL. It was added in MySQL 5.6.6 under the name
--server-public-key and renamed in 5.6.7 to
Suppress all normal output.
Do not use memory allocation checking.
sleep commands in the test case
file to sleep
num seconds. This
option does not affect
As of MySQL 5.0.23, an option value of 0 can be used, which
sleep commands in
the test case.
The socket file to use when connecting to
localhost (which is the default host).
Execute DML statements within a stored procedure. For every DML statement, mysqltest creates and invokes a stored procedure that executes the statement rather than executing the statement directly.
Specify how many lines of the result to include in the output if the test fails because an SQL statement fails. The default is 0, meaning no lines of result printed.
Read test input from this file. The default is to read from the standard input.
If given, the number of millisecond spent running the test will be written to this file. This is used by mysql-test-run.pl for its reporting.
The temporary directory where socket files are created.
The MySQL user name to use when connecting to the server.
Verbose mode. Print out more information about what the program does.
Display version information and exit.
SELECT statement is wrapped inside
a view. This option was added in MySQL 5.0.19.
Copyright © 2006, 2013, Oracle and/or its affiliates. All rights reserved. Legal Notices