If you try to run MySQLTuner on a default RHEL/CentOS 7 minimal install, you will receive an error due to “which” command not being found.
In order to resolve the error you need to add “which” to your CentOS/RHEL installation, or use the “–mysqladmin” switch to point to mysqladmin executable when running mysqltuner.pl.
When you try to execute MySQLTuner, you will receive a message like this:
# perl mysqltuner.pl Can't exec "which": No such file or directory at mysqltuner.pl line 905 (#1) (W exec) A system(), exec(), or piped open call could not execute the named program for the indicated reason. Typical reasons include: the permissions were wrong on the file, the file wasn't found in $ENV{PATH}, the executable in question was compiled for another architecture, or the #! line in a script points to an interpreter that can't be run for similar reasons. (Or maybe your system doesn't support #! at all.) Use of uninitialized value $mysqladmincmd in scalar chomp at mysqltuner.pl line 907 (#1) (W uninitialized) An undefined value was used as if it were already defined. It was interpreted as a "" or a 0, but maybe it was a mistake. To suppress this warning assign a defined value to your variables. To help you figure out what was undefined, perl will try to tell you the name of the variable (if any) that was undefined. In some cases it cannot do this, so it also tells you what operation you used the undefined value in. Note, however, that perl optimizes your program anid the operation displayed in the warning may not necessarily appear literally in your program. For example, "that $foo" is usually optimized into "that " . $foo, and the warning will refer to the concatenation (.) operator, even though there is no . in your program. Use of uninitialized value $mysqladmincmd in -e at mysqltuner.pl line 908 (#1) Use of uninitialized value $mysqladmincmd in -e at mysqltuner.pl line 913 (#1) [!!] Couldn't find mysqladmin in your $PATH. Is MySQL installed?
If you check the reported lines in mysqltuner.pl file, you will see that reported variable mysqladmincmd is found by looking for path of mysqladmin with “which mysqladmin” command.
# sed -n '905p;908p;913p' mysqltuner.pl $mysqladmincmd = `which mysqladmin`; if ( !-e $mysqladmincmd && $opt{mysqladmin} ) { elsif ( !-e $mysqladmincmd ) {
You can install “which” with following command.
yum -y install which
After installing the rpm, you will be able to execute mysqltuner.pl file.
Alternative to installing “which” is to run MySQLTuner with “–mysqladmin” switch and define the path to mysqladmin executable.
# perl mysqltuner.pl --help MySQLTuner 1.6.0 - MySQL High Performance Tuning Script Bug reports, feature requests, and downloads at http://mysqltuner.com/ Maintained by Major Hayden (major@mhtx.net) - Licensed under GPL Important Usage Guidelines: To run the script with the default options, run the script without arguments Allow MySQL server to run for at least 24-48 hours before trusting suggestions Some routines may require root level privileges (script will provide warnings) You must provide the remote server's total memory when connecting to other servers Connection and Authentication --host Connect to a remote host to perform tests (default: localhost) --socket Use a different socket for a local connection --port Port to use for connection (default: 3306) --user Username to use for authentication --pass Password to use for authentication --mysqladmin Path to a custom mysqladmin executable --mysqlcmd Path to a custom mysql executable --noask Dont ask password if needed Performance and Reporting Options --skipsize Don't enumerate tables and their types/sizes (default: on) (Recommended for servers with many tables) --skippassword Don't perform checks on user passwords(default: off) --checkversion Check for updates to MySQLTuner (default: don't check) --forcemem Amount of RAM installed in megabytes --forceswap Amount of swap memory configured in megabytes --passwordfile Path to a password file list(one password by line) Output Options: --silent Don't output anything on screen --nogood Remove OK responses --nobad Remove negative/suggestion responses --noinfo Remove informational responses --debug Print debug information --dbstat Print database information --idxstat Print index information --nocolor Don't print output in color --buffers Print global and per-thread buffer values --outputfile Path to a output txt file --reportfile Path to a report txt file --template Path to a template file
On CentOS 7 path to mysqladmin executable is “/usr/bin/mysqladmin”.
This is an example of a command which runs MySQL tuner, by manually specifying MySQL user and password, and path to mysqladmin executable.
perl mysqltuner.pl --user root --pass yourpassword --mysqladmin /usr/bin/mysqladmin