Skip to content

Commit

Permalink
Using --defaults-file ignores the .my.cnf #605
Browse files Browse the repository at this point in the history
  • Loading branch information
Jean-Marie RENOUARD committed Sep 13, 2022
1 parent 2259dfc commit fdd42e7
Showing 1 changed file with 20 additions and 3 deletions.
23 changes: 20 additions & 3 deletions mysqltuner.pl
Original file line number Diff line number Diff line change
@@ -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 - [email protected]
# Copyright (C) 2015-2022 Jean-Marie Renouard - [email protected]
Expand Down Expand Up @@ -57,7 +57,7 @@ package main;
#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
Expand Down Expand Up @@ -108,6 +108,7 @@ package main;
"reportfile" => 0,
"verbose" => 0,
"defaults-file" => '',
"defaults-extra-file" => '',
"protocol" => '',
);

Expand Down Expand Up @@ -140,6 +141,7 @@ package main;
'pfstat', 'nopfstat',
'idxstat', 'noidxstat',
'server-log=s', 'protocol=s',
'defaults-extra-file=s',
)
or pod2usage(
-exitval => 1,
Expand Down Expand Up @@ -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";
Expand Down Expand Up @@ -6905,7 +6921,7 @@ sub which {
=head1 NAME
MySQLTuner 2.0.6 - MySQL High Performance Tuning Script
MySQLTuner 2.0.7 - MySQL High Performance Tuning Script
=head1 IMPORTANT USAGE GUIDELINES
Expand All @@ -6928,6 +6944,7 @@ =head1 CONNECTION AND AUTHENTICATION
--mysqladmin <path> Path to a custom mysqladmin executable
--mysqlcmd <path> Path to a custom mysql executable
--defaults-file <path> Path to a custom .my.cnf
--defaults-extra-file <path> Path to a extra custom config file
--server-log <path> Path to explicit log file (error_log)
=head1 PERFORMANCE AND REPORTING OPTIONS
Expand Down

0 comments on commit fdd42e7

Please sign in to comment.