13

I had to reboot in the middle of a large data import. I only have one mysql database, which has now been corrupted.

How can I completely remove mysql and reinstall it? I've tried apt-get purge mysql-server, then removing /var/lib/mysql/* and reinstalling, but apt-get does not prompt me for a root name and password nor does it recreate the /var/lib/mysql files. How can I reinstall?

18

You should do the following:

apt-get purge mysql-server mysql-common mysql-client-<version>
rm -rf /var/lib/mysql
rm -rf /etc/mysql*

Then you can reinstall in full.

  • thanks! also had to add the version to mysql-server-<version> – cwd Dec 24 '11 at 6:11
  • +1 for mentioning removal of /var/lib/mysql . Keeping that can disallow you performing clean install because it seems it keeps some information about the upgrade. – dimir Feb 26 '16 at 13:08
1

It's much easier to execute this:

sudo mysqld --initialize

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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