I finally got a Raspberry Pi for Christmas and decided to set it up as a home web server. I have nginx with PHP set up and working. I came to install MySQL and ran sudo apt-get install mysql-server.

When setting the password I used a 32-character generated password with letters, numbers and symbols, however I don't believe it copied into the terminal correctly as I could not login with this password after the install.

After trying to reset the password mysqld_safe --skip-grant-tables seemed to prevent me from connecting to MySQL altogether (no sockets or network access was available after I started MySQL with this flag). I decided a better approach would be to just completely re-install MySQL as I had not set up any databases yet anyway.

After doing plenty of apt-get purge mysql-server and trying to remove various folders I found that, apt-get purge mysql-server followed by a apt-get autoremove and then a restart seemed to correctly remove MySQL (or so I thought) as the next install asked for a new root password.

As this install finished, it failed to set the MySQL Unix user password (I had forgotten to remove it). This meant that MySQL couldn't start and the installation is now sat in a partial state. Whenever I used apt-get to purge or autoremove, it again attempts to complete the install. I've tried updating the MySQL user to the new password I set. However, this has not allowed the install to complete.

How can I get apt-get to just rollback the install so I can start again rather than continuing to keep trying to complete a broken install?

2 Answers 2


I finally figured it out with help from a friend. It was dpkg --purge mysql-server and then the same again for another package that had gotten stuck in a partial install.

After the purge I simply removed the remaining MySQL user and installed mysql-server again which asked for a root password and correctly added a user to the system.


You could try removing the password:

sudo nano /etc/shadow

then locate the line about mysql:

mysql:[password hash here]:14804:0:99999:7:::

and replace the hash with *, which means no password.

  • 1
    just tried this and doing apt-get purge, apt-get autoremove or apt-get remove still just shows apt-get trying to complete the mysql-server install. Cant seem to find a way to force an uninstall of a partial install Dec 27, 2012 at 18:28

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.