Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

Please help!

There are server issues and MySql is no longer running on our server (Ubuntu). The service is not recognized and needs to be reinstalled. Unfortunately, the database has not been backed up for 48 hours and that is a lot of information.

How do I reinstall MySql AND keep all my database data? Please note - I can't access mysql at all. I can't use command line mysql nor phpmyadmin.

Thanks in advance and let me know if I am missing important details.

share|improve this question
    
Hello, your problem can have other origin than package re-installation. What do you mean by service not recognized? –  Spack Apr 18 '13 at 22:15
    
Check this 2nd question for concerns about WHY did this happen - serverfault.com/questions/500746/… –  Christopher Ickes Apr 18 '13 at 22:35
    
Did you try restarting Mysql? Keep in mind, Mysql stocks a sock file, mysql.sock I think in /tmp/ usually. It will not restart if that file is still there. You will have to delete that file and restart mysql. –  Nikolas Sakic Apr 19 '13 at 3:43

2 Answers 2

up vote 1 down vote accepted

MySQL database files are stored in /var/lib/mysql. This folder stays untouched when you remove or re-install the MySQL package.

It is also a good idea to make a backup of those files (after stopping the MySQL service) if you want to sleep on both ears.

share|improve this answer
1  
Don't use a apt-get purge though, purge does remove all the data. –  Zoredache Apr 18 '13 at 22:18

backup:

mysqldump -u root -p[root_password] [database_name] > dumpfilename.sql

restore:

mysql -u root -p[root_password] [database_name] < dumpfilename.sql

You can also edit the sql backup file in your favorite text editor.

share|improve this answer
    
Mysqldump requires a working server. Since he mentioned something is broke, I am not sure this will help much. –  Zoredache Apr 19 '13 at 8:11
    
"Please note - I can't access mysql at all." –  Christopher Ickes Apr 22 '13 at 12:54

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.