MySQL data retained after OS reinstall 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:

STEP 01

service mysql stop
rpm -qa | grep i mysql


You might see the following output

MySQL-shared-compat-5.6.12-1.rhel5.x86_64
MySQL-devel-5.6.12-1.rhel5.x86_64
MySQL-client-5.6.12-1.rhel5.x86_64
MySQL-shared-5.6.12-1.rhel5.x86_64
MySQL-server-5.6.12-1.rhel5.x86_64
MySQL-python-1.2.3-0.3.c1.1.el6.x86_64
perl-DBD-MySQL-4.013-3.el6.x86_64


STEP 02

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

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

STEP 03

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,