16

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?

0

2 Answers 2

21

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.

2
  • 1
    thanks! also had to add the version to mysql-server-<version>
    – cwd
    Commented Dec 24, 2011 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
    Commented Feb 26, 2016 at 13:08
1

It's much easier to execute this:

sudo mysqld --initialize
1
  • mysqld 5.6.30 doesn't seem to have this switch. Commented Jan 1, 2017 at 1:46

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .