Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 26 additions & 0 deletions mysqltuner.pl
Original file line number Diff line number Diff line change
Expand Up @@ -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 = <STDIN>;
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;
Expand Down