diff --git a/mysqltuner.pl b/mysqltuner.pl index f65f0da6e..f8cb36aac 100755 --- a/mysqltuner.pl +++ b/mysqltuner.pl @@ -1100,6 +1100,32 @@ sub mysql_setup { return 1; } else { + # If password was not provided and noask is not set, prompt for it + if ( $opt{pass} eq 0 && $opt{'noask'} == 0 ) { + print STDERR + "Please enter your MySQL administrative password: "; + system("stty -echo >$devnull 2>&1"); + my $password = ; + system("stty echo >$devnull 2>&1"); + chomp($password); + + $mysqllogin = "-u $opt{user}"; + if ( length($password) > 0 ) { + if ($is_win) { + $mysqllogin .= " -p\"$password\""; + } + else { + $mysqllogin .= " -p'$password'"; + } + } + $mysqllogin .= $remotestring; + + $loginstatus = `$mysqladmincmd ping $mysqllogin 2>&1`; + if ( $loginstatus =~ /mysqld is alive/ ) { + goodprint "Logged in using credentials with prompted password"; + return 1; + } + } badprint "Attempted to use login credentials, but they were invalid"; exit 1;