From 18bab70c847905a5c5bfc2e3f3960a7e4bfa56da Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Markus=20K=C3=B6berl?= Date: Wed, 20 Apr 2011 13:23:30 +0200 Subject: [PATCH 1/3] use the maintanance account on debian system --- mysqltuner.pl | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/mysqltuner.pl b/mysqltuner.pl index 6d23b35..60fb98d 100755 --- a/mysqltuner.pl +++ b/mysqltuner.pl @@ -292,6 +292,14 @@ sub mysql_setup { badprint "Attempted to use login credentials from Plesk, but they failed.\n"; exit 0; } + } elsif ( -r "/etc/mysql/debian.cnf" and $doremote == 0 ){ + # It's a debian system, use the maintenance account + $mysqllogin = "-u `awk '\$1 ~ /user/ {print \$3}' /etc/mysql/debian.cnf | head -n 1` -p`awk '\$1 ~ /password/ {print \$3}' /etc/mysql/debian.cnf | head -n 1`"; + my $loginstatus = `mysqladmin ping $mysqllogin 2>&1`; + unless ($loginstatus =~ /mysqld is alive/) { + badprint "Attempted to use login credentials from debian maintenance account, but they failed.\n"; + exit 0; + } } else { # It's not Plesk, we should try a login my $loginstatus = `mysqladmin $remotestring ping 2>&1`; From 2e347611ff7f78d9ef0b6410d90a02f0cd550b50 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Markus=20K=C3=B6berl?= Date: Thu, 21 Apr 2011 08:32:29 +0200 Subject: [PATCH 2/3] use the option --defaults-file ... --- mysqltuner.pl | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/mysqltuner.pl b/mysqltuner.pl index 60fb98d..962e1db 100755 --- a/mysqltuner.pl +++ b/mysqltuner.pl @@ -294,8 +294,8 @@ sub mysql_setup { } } elsif ( -r "/etc/mysql/debian.cnf" and $doremote == 0 ){ # It's a debian system, use the maintenance account - $mysqllogin = "-u `awk '\$1 ~ /user/ {print \$3}' /etc/mysql/debian.cnf | head -n 1` -p`awk '\$1 ~ /password/ {print \$3}' /etc/mysql/debian.cnf | head -n 1`"; - my $loginstatus = `mysqladmin ping $mysqllogin 2>&1`; + $mysqllogin = "--defaults-file=/etc/mysql/debian.cnf"; + my $loginstatus = `mysqladmin $mysqllogin ping 2>&1`; unless ($loginstatus =~ /mysqld is alive/) { badprint "Attempted to use login credentials from debian maintenance account, but they failed.\n"; exit 0; From 27f1454b0eb6b7c1ad9ebba6ad5265aeacf798f7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Markus=20K=C3=B6berl?= Date: Thu, 21 Apr 2011 14:36:10 +0200 Subject: [PATCH 3/3] update comments and logging messages --- mysqltuner.pl | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/mysqltuner.pl b/mysqltuner.pl index 962e1db..f61881c 100755 --- a/mysqltuner.pl +++ b/mysqltuner.pl @@ -293,15 +293,18 @@ sub mysql_setup { exit 0; } } elsif ( -r "/etc/mysql/debian.cnf" and $doremote == 0 ){ - # It's a debian system, use the maintenance account + # We have a debian maintenance account, use it $mysqllogin = "--defaults-file=/etc/mysql/debian.cnf"; my $loginstatus = `mysqladmin $mysqllogin ping 2>&1`; - unless ($loginstatus =~ /mysqld is alive/) { + if ($loginstatus =~ /mysqld is alive/) { + goodprint "Logged in using credentials from debian maintenance account.\n"; + return 1; + } else { badprint "Attempted to use login credentials from debian maintenance account, but they failed.\n"; exit 0; } } else { - # It's not Plesk, we should try a login + # It's not Plesk or debian, we should try a login my $loginstatus = `mysqladmin $remotestring ping 2>&1`; if ($loginstatus =~ /mysqld is alive/) { # Login went just fine