I had mysql running on my VPS. Today it crashed for no good reason!

I tried service mysql start, it gave me start: Job failed to start.

First thing I did was to backup /var/lib/mysql which contained folders corresponding to my databases and these other files:

  • debian-5.5.flag
  • ibdata1
  • ib_logfile0
  • ib_logfile1
  • mysql_upgrade_info

I removed /etc/mysql and did sudo apt-get purge mysql-server mysql-common and then installed everything again, the result was the same: start: Job failed to start.

I went to /var/lib/mysql/ and deleted ib* files. I could start mysql then, but some of the tables were problematic: I could see their names in PhpMyAdmin, but when tried to run queries, mysql errored out that the table doesn't exist.

I assume ibdata1 is corrupted! I put innodb_force_recovery = 0 and tried it upto innodb_force_recovery = 6, none of them worked and I got the same error when I tried to start mysql.

I still have the whole /var/lib/mysql backup.

Any ideas why this happened and how I can recover the data and start mysql again?


What You make right - it is backup all files from /var/lib/mysql

all other steps - wrong

Your current error (in PHPMyAdmin with phantom tables) - because You have Your database folder with .frm files for table structure, and empty (new) ibdata.

What You can do now - revert all back (restore files in it original place) Then You can: - check error log file, for error message - start change innodb_force_recovery from 1 to 6

  • Thanks :) I already have checked the log files! nothing useful there when I changed innodb_force_recovery. I suspected mysqld doesn't read /etc/mysql/my.cnf, i ran mysqld --innodb_force_recovery=1 and it worked!! Thanks anyway, you kind of pointed me into the right direction. Still no idea why it crashed in the first place, and why it doesn't care about my.cnf.
    – Aᴍɪʀ
    Mar 10 '17 at 13:50

At the end mysqld --innodb_force_recovery=1 did the trick! Still don't know why it wasn't reading innodb_force_recovery=1 from the config files. But passing the argument directly to the mysqld worked!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.