From 83a6413ddaa5bb4f8d5523ddb9771e4745d31502 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Mon, 22 Dec 2025 07:44:05 +0000 Subject: [PATCH 1/3] Initial plan From 26dd18d5dcf42af5681d2aedbae30f342de1940f Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Mon, 22 Dec 2025 07:49:26 +0000 Subject: [PATCH 2/3] Add password prompting when --user provided without --pass Co-authored-by: jmrenouard <620907+jmrenouard@users.noreply.github.com> --- mysqltuner.pl | 40 +++++++++++++++++++++++++++++++++++++--- 1 file changed, 37 insertions(+), 3 deletions(-) diff --git a/mysqltuner.pl b/mysqltuner.pl index f65f0da6e..56dd89c8f 100755 --- a/mysqltuner.pl +++ b/mysqltuner.pl @@ -1100,9 +1100,43 @@ sub mysql_setup { return 1; } else { - badprint - "Attempted to use login credentials, but they were invalid"; - exit 1; + # 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"); + print STDERR "\n"; + 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; + } + else { + badprint + "Attempted to use login credentials, but they were invalid"; + exit 1; + } + } + else { + badprint + "Attempted to use login credentials, but they were invalid"; + exit 1; + } } } From 180a5d677993bc80136ce44618dc057fdda5215f Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Mon, 22 Dec 2025 07:51:35 +0000 Subject: [PATCH 3/3] Refactor: consolidate duplicate error handling in password prompt Co-authored-by: jmrenouard <620907+jmrenouard@users.noreply.github.com> --- mysqltuner.pl | 14 +++----------- 1 file changed, 3 insertions(+), 11 deletions(-) diff --git a/mysqltuner.pl b/mysqltuner.pl index 56dd89c8f..f8cb36aac 100755 --- a/mysqltuner.pl +++ b/mysqltuner.pl @@ -1107,7 +1107,6 @@ sub mysql_setup { system("stty -echo >$devnull 2>&1"); my $password = ; system("stty echo >$devnull 2>&1"); - print STDERR "\n"; chomp($password); $mysqllogin = "-u $opt{user}"; @@ -1126,17 +1125,10 @@ sub mysql_setup { goodprint "Logged in using credentials with prompted password"; return 1; } - else { - badprint - "Attempted to use login credentials, but they were invalid"; - exit 1; - } - } - else { - badprint - "Attempted to use login credentials, but they were invalid"; - exit 1; } + badprint + "Attempted to use login credentials, but they were invalid"; + exit 1; } }