major / MySQLTuner-perl

MySQLTuner is a script written in Perl that will assist you with your MySQL configuration and make recommendations for increased performance and stability.
GNU General Public License v3.0
8.93k stars 1.29k forks source link

bug (?) script fails on centos 6.8 due to a number of uninitialized vars #275

Closed juliyvchirkov closed 7 years ago

juliyvchirkov commented 7 years ago

hello

mysqltuner script v1.7.0 fails on server running centos 6.8 (minimal install, no x [if this matters]) w/ perl v5.10.1 & mysql v5.7.15 (i.e. percona server v5.7.15-9) due to a number of uninitialized vars, viz. — $myvar{"version"} — $mysqlvermajor — $mystat{"Questions"}

# cat /etc/redhat-release 
CentOS release 6.8 (Final)

# which perl
/usr/bin/perl

# /usr/bin/perl -v
This is perl, v5.10.1 (*) built for x86_64-linux-thread-multi

# which env
/bin/env

# /bin/env --version
env (GNU coreutils) 8.4
Copyright (C) 2010 Free Software Foundation, Inc.

# ls -lah /usr/bin/env
lrwxrwxrwx 1 root root 13 Aug 28 02:27 /usr/bin/env -> ../../bin/env

# which mysqld
/usr/sbin/mysqld

# /usr/sbin/mysqld --version
/usr/sbin/mysqld  Ver 5.7.15-9 for Linux on x86_64
(Percona Server (GPL), Release 9, Revision f0e3400)

# which mysqltuner
/sbin/mysqltuner

# cat /sbin/mysqltuner
#!/bin/bash
cd /var/lib/mysql/tuner
/bin/env /usr/bin/perl /var/lib/mysql/tuner/mysqltuner.pl "$@"
cd $OLDPWD

# /bin/ls -lah /var/lib/mysql/tuner
total 888K
drwxr-xr-x  2 root  root  4.0K Nov 20 04:10 .
drwxr-x--x 15 mysql mysql 136K Nov 20 03:46 ..
-rw-r--r--  1 root  root  3.9K Nov 20 02:50 basic_passwords.txt
-rwxr-xr-x  1 root  root  200K Nov 20 02:50 mysqltuner.pl
-rw-r--r--  1 root  root  540K Nov 20 02:50 vulnerabilities.csv

# /sbin/mysqltuner --help
MySQLTuner 1.7.0 - MySQL High Performance Tuning Script

I've turned debug on for output to provide as much data as possible

# /sbin/mysqltuner --debug

MySQLTuner 1.7.0 - Major Hayden major@mhtx.net Bug reports, feature requests, and downloads at http://mysqltuner.com/ Run with '--help' for additional options and output filtering

[--] Skipped version check for MySQLTuner script [DG] MySQL Client: /usr/bin/mysql would have been started with the following arguments: --port=3306 --socket=/var/lib/mysql/mysql.sock [DG] MySQL Client: /usr/bin/mysql [DG] /usr/bin/mysqladmin ping 2>&1 Please enter your MySQL administrative login: root Please enter your MySQL administrative password: [DG] Physical Memory: 4016533504 [DG] Swap Memory: 2113925120 [DG] PERFORM: SELECT VERSION() [DG] select_array: return code : 0 [DG] VERSION: 5.7.15 [DG] PERFORM: SHOW VARIABLES [DG] select_array: return code : 0 [DG] PERFORM: SHOW GLOBAL VARIABLES [DG] select_array: return code : 0 [DG] PERFORM: SHOW STATUS [DG] select_array: return code : 0 [DG] PERFORM: SHOW GLOBAL STATUS [DG] select_array: return code : 0 [DG] PERFORM: SHOW ENGINES [DG] select_array: return code : 0 [DG] $VAR1 = 'PERFORMANCE_SCHEMA YES Performance Schema NO NO NO'; [DG] PERFORM: SHOW SLAVE STATUS\G [DG] select_array: return code : 0 [DG] PERFORM: SHOW SLAVE HOSTS [DG] select_array: return code : 0 [DG] PERFORM: \s [DG] select_array: return code : 0 [DG] Current database => [DG] Current user => root@localhost [DG] SSL => Not in use [DG] Server version => 5.7.15-9-log Percona Server (GPL), Release 9, Revision f0e3400 [DG] Protocol version => 10 [DG] Connection => Localhost via UNIX socket [DG] Server characterset => utf8 [DG] Db characterset => utf8 [DG] Client characterset => utf8 [DG] Conn. characterset => utf8 [DG] UNIX socket => /var/lib/mysql/mysql.sock [DG] Uptime => 11 hours 26 min 46 sec Use of uninitialized value $myvar{"version"} in pattern match (m//) at /var/lib/mysql/tuner/mysqltuner.pl line 1697, line 2 (#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 and 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 $mysqlvermajor in int at /var/lib/mysql/tuner/mysqltuner.pl line 1724, line 2 (#1) Use of uninitialized value $myvar{"version"} in concatenation (.) or string at /var/lib/mysql/tuner/mysqltuner.pl line 1702, line 2 (#1) [!!] Your MySQL version is EOL software! Upgrade soon! [OK] Operating on 64-bit architecture

-------- Storage Engine Statistics -------- [DG] PERFORM: SHOW DATABASES

[ ... skipped ... ]

-------- Security Recommendations -------- Use of uninitialized value $myvar{"version"} in pattern match (m//) at /var/lib/mysql/tuner/mysqltuner.pl line 1508, line 2 (#1) [DG] Password column = password [DG] PERFORM: SELECT CONCAT(user, '@', host) FROM mysql.user WHERE TRIM(USER) = '' OR USER IS NULL [DG] select_array: return code : 0 [DG] $VAR1 = [];

[OK] There are no anonymous accounts for any database users Use of uninitialized value $mysqlvermajor in int at /var/lib/mysql/tuner/mysqltuner.pl line 1736, line 2 (#1) [!!] No more password checks for MySQL version <=5.1 [!!] MySQL version <=5.1 are deprecated and end of support.

-------- CVE Security Recommendations -------- Use of uninitialized value $mysqlvermajor in concatenation (.) or string at /var/lib/mysql/tuner/mysqltuner.pl line 1107, <$fh> line 1 (#1) Use of uninitialized value $mysqlvermajor in int at /var/lib/mysql/tuner/mysqltuner.pl line 1736, <$fh> line 1 (#1) [DG] Comparing .0.0 with 4.0.20 : <= Use of uninitialized value $mysqlvermajor in numeric eq (==) at /var/lib/mysql/tuner/mysqltuner.pl line 1113, <$fh> line 1 (#1) Use of uninitialized value $mysqlvermajor in concatenation (.) or string at /var/lib/mysql/tuner/mysqltuner.pl line 1107, <$fh> line 2 (#1) Use of uninitialized value $mysqlvermajor in int at /var/lib/mysql/tuner/mysqltuner.pl line 1736, <$fh> line 2 (#1) [DG] Comparing .0.0 with 4.0.21 : <= Use of uninitialized value $mysqlvermajor in numeric eq (==) at /var/lib/mysql/tuner/mysqltuner.pl line 1113, <$fh> line 2 (#1) Use of uninitialized value $mysqlvermajor in concatenation (.) or string at /var/lib/mysql/tuner/mysqltuner.pl line 1107, <$fh> line 3 (#1) Use of uninitialized value $mysqlvermajor in int at /var/lib/mysql/tuner/mysqltuner.pl line 1736, <$fh> line 3 (#1)

[ ... skipped 'cause of identical error thru the loop ... ]

[DG] Comparing .0.0 with 7.0.11 : <= Use of uninitialized value $mysqlvermajor in numeric eq (==) at /var/lib/mysql/tuner/mysqltuner.pl line 1113, <$fh> line 512 (#1) [OK] NO SECURITY CVE FOUND FOR YOUR VERSION Use of uninitialized value $mystat{"Questions"} in numeric lt (<) at /var/lib/mysql/tuner/mysqltuner.pl line 2059 (#1) [!!] Your server has not answered any queries - cannot continue...

[ ... script exits ... ]

I've also compiled & tried mysqltuner.pl w/ fresh perl v5.20.2 but unfortunately the result has been the same as above

hope it helps; if you need some additional information — you are welcome to request

jmrenouard commented 7 years ago

Hi @juliyvchirkov

It's happening when the following commands failed: mysql> show variables; ERROR 1146 (42S02): Table 'performance_schema.session_variables' doesn't exist

You probably migrate from mariaDB or MySQL 5.X<7 without creating a new database and reimport dump.

I check this and get the same results. After you perform this migration operations all seems to be fine. Moreover, you will be able to monitor your database as well.

jmrenouard commented 7 years ago

I closed this issue. MySQLTuner doesn't have to configure MySQL 5.7 with show_compatibility_56 is ON,

Please refer to migration notes here: https://dev.mysql.com/doc/refman/5.7/en/performance-schema-variable-table-migration.html