3

I want to completely remove and re-install mysql on Ubuntu 11.10. I've tried removing it by running:

apt-get remove --purge 'mysql-.*'

But when I re-install it, the old databases are still there, so it obviously wasn't completely removes. How do I remove:

  • the server
  • databases
  • configuration files
3
  • removing packages won't remove your databases, you will need to delete them manually. You can find database files in /var/lib/mysql Mar 14, 2012 at 19:53
  • @DmitryAlexeyev, I beg to differ the purge code in /var/lib/dpkg/info/mysql-server-5.1.postrm clearly has a block of code in place that should be removing /var/lib/mysql if the purge executed properly.
    – Zoredache
    Mar 14, 2012 at 19:59
  • 1
    @Zoredache You are correct; however, the logic in that script is bad. It only removes (with prompting) /var/lib/mysql if /usr/sbin/mysqld if it isn't executable. Alas, that file is provided by mysql-server-core-5.1. Because mysql-server-5.1 depends on mysql-server-core-5.1, during a removal mysql-server-5.1 is removed first; thus /usr/sbin/mysqld will still exist and the data directory won't be removed. (Verified by running dpkg --force-depends --purge mysql-server-core-5.1 and then dkg --force-depends --purge mysql-server-5.1. N.B. this is not a solution to the question.) Mar 14, 2012 at 23:02

1 Answer 1

3

Delete the default MySQL data directory is /var/lib/mysql. And finally delete the configuration directory that resides in /etc/mysql.

Reinstall and you should be good to go!

2
  • oh, is that an ubuntu packaging thing?, I have the mysql configuration file as /etc/my.cnf
    – Tom
    Mar 14, 2012 at 20:01
  • Although the paths might vary a little bit, the general thumb rule is configuration lies inside /etc. Mar 14, 2012 at 20:06

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .