Server Fault is a question and answer site for system and network administrators. 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 installed mysql 5.5 in /usr/local/mysql . If I apt-get remove the old package, it won't delete the data directory in /var/lib/mysql will it?

UPDATE: Yes it's an official standard generic Ubuntu package

share|improve this question
up vote 6 down vote accepted

The one way to know for certain is to inspect the /var/lib/dpkg/info/mysql-server-5.1.postrm script. Without knowing if you are using the official package, or which version of the package, I cannot say with certainty what will happen.

Typically a apt-get remove will not purge any data or configuration scripts. If you want everything to be removed you use apt-get purge.

But why chance it? Make a backup first, and then remove.

share|improve this answer
I seem rm -rf /var/lib/mysql in a block conditional on if [ "$1" = "purge" -a ! \( -x /usr/sbin/mysqld -o -L /usr/sbin/mysqld \) ]; the n – ʞɔıu Feb 10 '11 at 21:54
I believe it's intended to remove /var/lib/mysql on purge, but in actual fact it doesn't:… I can verify that a purge doesn't actually remove the directory in Ubuntu 12.04, MySQL 5.5. – meowsqueak Jun 21 '12 at 4:37

Your Answer


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.