Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

I have MySQL installed on my localhost. What happens if I have a problem with mysql and I want to re-install it again? Do I lose my existing databases?

share|improve this question
    
Wouldn't it be better to explain your problems wit mysql. So people can try to help you fix those. Re installing is more a windows-way of solving problems. –  rechengehirn Dec 4 '13 at 17:47
add comment

1 Answer

No, reinstalling mysql-server will not delete you database files, only delete the package files of mysql-server. You will be able to access your files(database) after you re-install the server.

To purge and install mysql-server:

sudo apt-get purge mysql-server
sudo apt-get install mysql-server

If you want to delete the database too, you must delete it first before you remove mysql. To delete the database cleanly, on the mysql prompt type:

drop database <database_name>

I found another way to delete the database files, but I am not sure whether this is a clean way to delete the database, so take it with a pinch of salt:

From a question on stackoverflow:

It(The location of the database files) is installation specific, but if you've /var/lib/mysql , then:

  • MyISAM tables will be stored in individual files in /var/lib/mysql/databasename/
  • InnoDB resides in /var/lib/mysql/ibdata (unless you've used the innodb_per_table setting, in which case it's stored much like for MyISAM tables)

So check the location of your databases in these two locations and delete the directory of the databases(requires superuser privileges to read and delete).

share|improve this answer
    
How do I do it in a way to delete my files, if I wanted to? –  aditya menon Mar 6 at 6:57
1  
@adityamenon: Edited to reflect that, thanks! –  Jobin Mar 6 at 10:21
1  
Thank you, too! :) –  aditya menon Mar 6 at 13:19
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.