Take the 2-minute tour ×
Database Administrators Stack Exchange is a question and answer site for database professionals who wish to improve their database skills and learn from others in the community. It's 100% free, no registration required.

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?

share|improve this question
add comment

1 Answer 1

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,

share|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
add comment

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.