MySQL won’t start after power loss

So I had a power outage this week and my Pi server restarted, after reboot I noticed that WordPress wouldn’t start anymore. Starting mysqld manually would cause the following error:

03:02:19 UTC – mysqld got signal 6 ;
This could be because you hit a bug. It is also possible that this binary
or one of the libraries it was linked against is corrupt, improperly built,
or misconfigured. This error can also be caused by malfunctioning hardware.

Most pages returned by Google say that the InnoDB is probably corrupted and suggest to force recovery in my.cnf using the flag

innodb_force_recovery = 4

The innodb_force_recovery takes a number from 1 to 6.

However, none of these options could get mysqld to start, I was always getting the same error.

Here is what I did to get it to work:

  1. In my.cnf add innodb_force_recovery = 6 in the [mysqld] section (mySQL manual)
  2. In my.cnf add innodb_purge_threads=0 (this what allowed mysqld to start in read only mode)
  3. Start mysqld (“mysqld –verbose” or “/etc/init.d/mysqld start”)
  4. Check for corruption: mysqlcheck -p –all-databases
  5. Find the corrupt table and do: myisamchk -r -v -f <table_name> (where the data file is stored)
  6. Using the mysql recovery command did not fix anything, it was unable to recover the error, but you are welcome to try
  7. Backup your data: mysqldump -A > /home/user/backup_dump.sql
  8. Stop mysqld
  9. Delete /var/lib/mysql/ib*
  10. Comment the 2 lines you added in my.cnf
  11. Restart my mysqld
  12. Restore from the SQL dump if needed

When corruption meets geekness

Moftasa posted this article on how he wrote a linux script that downloads all the obituaries published in Al Ahram newspaper between 2002 and 2008, finds all the names of people with Police titles then finds the family relations between them!

The script does the following:

  • The first step is to convert the HTML files downloaded by curl into one giant text file.
  • Then to move each separate obituary into a line of it’s own.
  • Extract officer names sandwiched between rank and place of work into a separate text file.
  • Search for the names of each officer through each obituary, family links between different officers can be discovered.
  • The output is in GraphViz .dot format.

This is as cool as the Oracle Of Bacon

Bravo Moftasa.