Project

General

Profile

Bug #65

MySQL Fails to Start on Ubuntu at Boot Time

Added by Daniel Curtis almost 12 years ago. Updated over 11 years ago.

Status:
Closed
Priority:
Immediate
Assignee:
Target version:
-
Start date:
02/06/2013
Due date:
% Done:

100%

Estimated time:
Spent time:

Description

An unknown incident caused MySQL to fail starting up at boot time. This wiped out all of the data from every table and corrupted the ibdata1 file. The engine used on this version of MySQL is InnoDB.

1. Check to see if the service is running:

sudo service mysql status

2. Attempt to start MySQL

sudo service mysql start

The service fails to start.

3. Backup the corrupt ib files

sudo mkdir /var/lib/mysql/bak
cp /var/lib/mysql/ib* /var/lib/mysql/bak

4. Start MySQL service with InnoDB recovery

mysqld --defaults-file=/etc/mysql/my.cnf --innodb-force-recovery=6

5. Dump the recovered MySQL databases to backup.sql

mysqldump -u root -p --all-databases > backup.sql

6. Stop MySQL service with InnoDB recovery

ps -aux | grep mysql
kill -s kill <PID#>

7. Purge the corrupt ib files.

NOTE: Remember to backup the corrupt ib files first. If something goes wrong with the working corrupt files, there will be nothing to fall back to.

sudo rm -rf /var/lib/mysql/ib*

8. Start the normal MySQL

sudo service mysql start

9. Import recovered databases from backup.sql

sudo mysql -u root -p < backup.sql

Also available in: Atom PDF