Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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?

share|improve this question
up vote 10 down vote accepted

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.

share|improve this answer
    
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 at 13:08

It's much easier to execute this:

sudo mysqld --initialize
share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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