You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The `PASSWORD()` function was removed in MySQL 8.0, causing errors when running MySQLTuner against newer versions of MySQL.
This commit addresses the issue by wrapping the specific code blocks that use the `PASSWORD()` function in a version check (`if (!mysql_version_ge(8))`).
This change ensures that:
- The script no longer produces errors on MySQL 8.0 and later.
- Security checks that do not rely on the `PASSWORD()` function are still executed on MySQL 8+, which is an improvement over the previous broader check that skipped the entire security section.
infoprint "Skipped due to unsupported feature for MySQL 8.0+";
2258
-
return;
2259
-
}
2260
2256
2261
2257
#exit 0;
2262
2258
if ( $opt{skippassword} eq 1 ) {
@@ -2377,15 +2373,17 @@ sub security_recommendations {
2377
2373
}
2378
2374
2379
2375
# Looking for User with user/ uppercase /capitalise user as password
2380
-
@mysqlstatlist = select_array
2376
+
if ( !mysql_version_ge(8) ) {
2377
+
@mysqlstatlist = select_array
2381
2378
"SELECT CONCAT(QUOTE(user), '\@', QUOTE(host)) FROM mysql.user WHERE user != '' AND (CAST($PASS_COLUMN_NAME as Binary) = PASSWORD(user) OR CAST($PASS_COLUMN_NAME as Binary) = PASSWORD(UPPER(user)) OR CAST($PASS_COLUMN_NAME as Binary) = PASSWORD(CONCAT(UPPER(LEFT(User, 1)), SUBSTRING(User, 2, LENGTH(User)))))";
2382
-
if (@mysqlstatlist) {
2383
-
foreachmy$line ( sort@mysqlstatlist ) {
2384
-
chomp($line);
2385
-
badprint "User " . $line . " has user name as password.";
2386
-
push( @generalrec,
2379
+
if (@mysqlstatlist) {
2380
+
foreachmy$line ( sort@mysqlstatlist ) {
2381
+
chomp($line);
2382
+
badprint "User " . $line . " has user name as password.";
2383
+
push( @generalrec,
2387
2384
"Set up a Secure Password for $line user: SET PASSWORD FOR $line = PASSWORD('secure_password');"
2388
-
);
2385
+
);
2386
+
}
2389
2387
}
2390
2388
}
2391
2389
@@ -2419,44 +2417,46 @@ sub security_recommendations {
2419
2417
my$nbins = 0;
2420
2418
my$passreq;
2421
2419
if (@passwords) {
2422
-
my$nbInterPass = 0;
2423
-
foreachmy$pass (@passwords) {
2424
-
$nbInterPass++;
2425
-
2426
-
$pass =~ s/\s//g;
2427
-
$pass =~ s/\'/\\\'/g;
2428
-
chomp($pass);
2429
-
2430
-
# Looking for User with user/ uppercase /capitalise weak password
2431
-
@mysqlstatlist =
2432
-
select_array
2420
+
if ( !mysql_version_ge(8) ) {
2421
+
my$nbInterPass = 0;
2422
+
foreachmy$pass (@passwords) {
2423
+
$nbInterPass++;
2424
+
2425
+
$pass =~ s/\s//g;
2426
+
$pass =~ s/\'/\\\'/g;
2427
+
chomp($pass);
2428
+
2429
+
# Looking for User with user/ uppercase /capitalise weak password
2430
+
@mysqlstatlist =
2431
+
select_array
2433
2432
"SELECT CONCAT(user, '\@', host) FROM mysql.user WHERE $PASS_COLUMN_NAME = PASSWORD('"
2434
-
. $pass
2435
-
. "') OR $PASS_COLUMN_NAME = PASSWORD(UPPER('"
2436
-
. $pass
2437
-
. "')) OR $PASS_COLUMN_NAME = PASSWORD(CONCAT(UPPER(LEFT('"
2438
-
. $pass
2439
-
. "', 1)), SUBSTRING('"
2440
-
. $pass
2441
-
. "', 2, LENGTH('"
2442
-
. $pass . "'))))";
2443
-
debugprint "There are " . scalar(@mysqlstatlist) . " items.";
2444
-
if (@mysqlstatlist) {
2445
-
foreachmy$line (@mysqlstatlist) {
2446
-
chomp($line);
2447
-
badprint "User '" . $line
2448
-
. "' is using weak password: $pass in a lower, upper or capitalize derivative version.";
2433
+
. $pass
2434
+
. "') OR $PASS_COLUMN_NAME = PASSWORD(UPPER('"
2435
+
. $pass
2436
+
. "')) OR $PASS_COLUMN_NAME = PASSWORD(CONCAT(UPPER(LEFT('"
2437
+
. $pass
2438
+
. "', 1)), SUBSTRING('"
2439
+
. $pass
2440
+
. "', 2, LENGTH('"
2441
+
. $pass . "'))))";
2442
+
debugprint "There are " . scalar(@mysqlstatlist) . " items.";
2443
+
if (@mysqlstatlist) {
2444
+
foreachmy$line (@mysqlstatlist) {
2445
+
chomp($line);
2446
+
badprint "User '" . $line
2447
+
. "' is using weak password: $pass in a lower, upper or capitalize derivative version.";
2449
2448
2450
-
push( @generalrec,
2449
+
push( @generalrec,
2451
2450
"Set up a Secure Password for $line user: SET PASSWORD FOR '"
goodprint "Your innodb_redo_log_capacity is sized to handle more than 1 hour of writes.";
6623
+
if ( hr_raw( $myvar{'innodb_redo_log_capacity'} ) < $hourly_rate ) {
6624
+
badprint
6625
+
"Your innodb_redo_log_capacity is not large enough to hold at least 1 hour of writes.";
6626
+
push( @adjvars,
6627
+
"innodb_redo_log_capacity (>= "
6628
+
. $suggested_redo_log_capacity_str
6629
+
. ")" );
6630
+
}
6631
+
else {
6632
+
goodprint
6633
+
"Your innodb_redo_log_capacity is sized to handle more than 1 hour of writes.";
6620
6634
}
6621
6635
6622
6636
# Sanity check against total InnoDB data size
6623
-
if ( defined$enginestats{'InnoDB'} and$enginestats{'InnoDB'} > 0 ) {
6637
+
if ( defined$enginestats{'InnoDB'} and$enginestats{'InnoDB'} > 0 )
6638
+
{
6624
6639
my$total_innodb_size = $enginestats{'InnoDB'};
6625
-
if ( $suggested_redo_log_capacity_bytes > $total_innodb_size * 0.25 ) {
6626
-
infoprint "The suggested innodb_redo_log_capacity (" . $suggested_redo_log_capacity_str . ") is more than 25% of your total InnoDB data size. This might be unnecessarily large.";
6640
+
if ( $suggested_redo_log_capacity_bytes >
6641
+
$total_innodb_size * 0.25 )
6642
+
{
6643
+
infoprint "The suggested innodb_redo_log_capacity ("
6644
+
. $suggested_redo_log_capacity_str
6645
+
. ") is more than 25% of your total InnoDB data size. This might be unnecessarily large.";
6627
6646
}
6628
6647
}
6629
-
} else {
6630
-
infoprint "Server uptime is less than 1 hour. Cannot make a reliable recommendation for innodb_redo_log_capacity.";
6648
+
}
6649
+
else {
6650
+
infoprint
6651
+
"Server uptime is less than 1 hour. Cannot make a reliable recommendation for innodb_redo_log_capacity.";
6631
6652
}
6632
6653
}
6633
6654
else {
@@ -6648,11 +6669,12 @@ sub mysql_innodb {
6648
6669
. ") if possible, so InnoDB Redo log Capacity equals 25% of buffer pool size."
6649
6670
);
6650
6671
push( @generalrec,
6651
-
"Be careful, increasing innodb_redo_log_capacity means higher crash recovery mean time"
6672
+
"Be careful, increasing innodb_redo_log_capacity means higher crash recovery mean time"
0 commit comments