16

Screenshot of the installation process

As you can see at the image (link above) I started an installation of mysql by typing

mysql_secure_installation

on the Ubuntu 20.04 terminal.

But now I just want to cancel (exit) the installation. The process is now in the password setting section (like in the image above).

I tried ctrl+x, ctrl+q, ctrl+d, ESC but none of them worked.

Should I just close the terminal window? (I want that nothing will be saved of the process)

I'm waiting for your help, thanks in advance.

Memin
  • 161
  • 1
  • 1
  • 3

4 Answers4

33

The Solution

From another terminal:

sudo kill $(ps aux | grep mysql_secure_installation | grep -v grep | awk '{print $2}')

Per qt-x's comment, if your system supports pgrep you can use:

sudo kill $(pgrep mysql_secure_installation)

You can then run 'mysql_secure_installation' again. But you may want to read the "Why I Know This" section below first....., which may explain why you have to exit 'mysql_secure_installation' in the first place [for some people].

Why I Know This

For some reason, recently I've had to set my root password first before running this script:

> mysql
mysql> ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password by 'mynewpassword';

Or I end up in an endless loop where I can't set the password, and the message is:

Failed! Error: SET PASSWORD has no significance for user ‘root’@’localhost’ as the authentication method used doesn’t store authentication data in the MySQL server
Bret Weinraub
  • 1,943
  • 15
  • 21
  • 1
    Shortcut for stoping the loop: sudo kill $(pgrep mysql_secure_installation) – qt-x Jun 12 '22 at 20:33
  • 2
    Thank you for the "Why I Know This" bit, this was the solution after an hour of searching -- changing the root password prior to starting my_secure_installation! – John S Jul 12 '22 at 17:27
  • However, this does not work as all efforts to connect to the server via ssh from another terminal failed – Emmanuel David Aug 28 '22 at 15:41
  • @EmmanuelDavid - yeah but that is going to be a separate and unrelated issue. – Bret Weinraub Aug 29 '22 at 19:37
15

ctrl+c will work, but only at the following position:

Do you wish to continue with the password provided?(Press y|Y for Yes, any other key for No) :

  • 1
    Works for me. The reason why it is not working on `New Password:` and `Re-enter new password:` is because it reads ^C like a character – cyberfrogg Jul 26 '22 at 22:12
  • Thank you! This worked for me and was useful since I was ssh'd into the machine and didn't want to have to open yet another terminal window. – DukeSilver Oct 09 '22 at 21:17
3

Maybe a simpler command to kill mysql_secure_installation

sudo pkill -f mysql_secure_installation

pgrep -af mysql_secure_installation to get the current state.

Pablo Bianchi
  • 1,824
  • 1
  • 26
  • 30
-5

very easy, just type ctrl+c it worked for me, don't know about you

Solus
  • 1
  • 1