From fdd42e76857532002b8037cafddec3e38983dde8 Mon Sep 17 00:00:00 2001 From: Jean-Marie RENOUARD Date: Tue, 13 Sep 2022 15:55:35 +0200 Subject: [PATCH] Using --defaults-file ignores the .my.cnf #605 --- mysqltuner.pl | 23 ++++++++++++++++++++--- 1 file changed, 20 insertions(+), 3 deletions(-) diff --git a/mysqltuner.pl b/mysqltuner.pl index 5192192..0a35e4e 100755 --- a/mysqltuner.pl +++ b/mysqltuner.pl @@ -1,5 +1,5 @@ #!/usr/bin/env perl -# mysqltuner.pl - Version 2.0.6 +# mysqltuner.pl - Version 2.0.7 # High Performance MySQL Tuning Script # Copyright (C) 2006-2022 Major Hayden - major@mhtx.net # Copyright (C) 2015-2022 Jean-Marie Renouard - jmrenouard@gmail.com @@ -57,7 +57,7 @@ use Cwd 'abs_path'; #use Env; # Set up a few variables for use in the script -my $tunerversion = "2.0.6"; +my $tunerversion = "2.0.7"; my ( @adjvars, @generalrec ); # Set defaults @@ -108,6 +108,7 @@ my %opt = ( "reportfile" => 0, "verbose" => 0, "defaults-file" => '', + "defaults-extra-file" => '', "protocol" => '', ); @@ -140,6 +141,7 @@ GetOptions( 'pfstat', 'nopfstat', 'idxstat', 'noidxstat', 'server-log=s', 'protocol=s', + 'defaults-extra-file=s', ) or pod2usage( -exitval => 1, @@ -915,6 +917,20 @@ sub mysql_setup { return 1; } } + elsif ( $opt{'defaults-extra-file'} ne '' and -r "$opt{'defaults-extra-file'}" ) { + + # defaults-extra-file + debugprint "defaults extra file detected: $opt{'defaults-extra-file'}"; + my $mysqlclidefaults = `$mysqlcmd --print-defaults`; + debugprint "MySQL Client Extra Default File: $opt{'defaults-extra-file'}"; + + $mysqllogin = "--defaults-extra-file=" . $opt{'defaults-extra-file'}; + my $loginstatus = `$mysqladmincmd $mysqllogin ping 2>&1`; + if ( $loginstatus =~ /mysqld is alive/ ) { + goodprint "Logged in using credentials from extra defaults file account."; + return 1; + } + } else { # It's not Plesk or Debian, we should try a login debugprint "$mysqladmincmd $remotestring ping 2>&1"; @@ -6905,7 +6921,7 @@ __END__ =head1 NAME - MySQLTuner 2.0.6 - MySQL High Performance Tuning Script + MySQLTuner 2.0.7 - MySQL High Performance Tuning Script =head1 IMPORTANT USAGE GUIDELINES @@ -6928,6 +6944,7 @@ You must provide the remote server's total memory when connecting to other serve --mysqladmin Path to a custom mysqladmin executable --mysqlcmd Path to a custom mysql executable --defaults-file Path to a custom .my.cnf + --defaults-extra-file Path to a extra custom config file --server-log Path to explicit log file (error_log) =head1 PERFORMANCE AND REPORTING OPTIONS