Something strange happened today.

I reinstalled my OS and then when I reinstalled MySQL workbench some of my old data was still there. I think the actual local db is empty, but all the connections, models, and listed servers are still there. I can't view which users still exist because I get an connection error. The server is running, though.

I have a backup. I do a dump nightly. I was going to restore from that, but I expected a clean slate when I reinstalled. Should I delete everything before moving ahead with the restore?

Does anyone have an idea why/how that happened?


I would expect the OS to be cognizant of already installed MySQL packages, but not the files under /var/lib/mysql. Sure, rpm and yum repository info gets reset with the OS. The best thing that I know of a mysql uninstall is the renaming of /etc/my.cnf.

What you could have have done was something like this:


service mysql stop
rpm -qa | grep i mysql

You might see the following output



You would then rpm -e or yum uninstall all these packages.

That still won't nix the files for MySQL. What next ?


Move the old datadir aside:

chown -R root:root /var/lib/mysql
mv /var/lib/mysql /var/lib/mysql_old

Now, the old mysql data is out of the way.

If you did not do these things before installing MySQL, a new install of MySQL will not overwrite the previous /var/lib/mysql. In light of this, I would not expect any OS installations to do this either.

After the OS reinstall, you probably tried to rpm or yum install MySQL again. This won't shove aside /var/lib/mysql. If you don't want the old /var/lib/mysql, no worries. Just redo Steps 1-3,

| improve this answer | |
  • 1
    An OS installation would only wipe out other data if you reformat the partition the data is on. If you have a single partition for your server (eg. just one mounted at /) and it's not recreated then all your data will persist after reinstallation. To wipe it out you need to use explicitly recreate the primary partition at the start of OS installation. Also, for added security you might want to look into using something like shred to make sure that old data is overwritten. – sehrope Aug 8 '13 at 22:12
  • @sehrope That's very true (+1). If no disk formatting was done, only then my answer would be a possibility. If you have any additional insights for the lingering mysql data, please share it with us. – RolandoMySQLDBA Aug 8 '13 at 22:16

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.