How to Solve Failed to Start MySQL Server After Database Crash? | 3 ways

Sometimes there might be a MySQL server crash due to unexpected errors and unable to start. This blog is going to introduce 3 solutions for you.

download-icon
Free Download
for VM, OS, DB, File, NAS, etc.
nick-zhao

Updated by Nick Zhao on 2022/12/31

Table of contents
  • Solution 1: Delete files in /var/lib/mysql

  • Solution 2: Forcing InnoDB Recovery (for emergency situation only)

  • Solution 3: Restart MySQL using backups (most useful)

MySQL is a very popular open-source database management system that can be used by many database-driven web applications. It can be installed on both Windows and Linux distributions, including CentOS, Debian, Oracle, Ubuntu, and more. However, sometimes there might be a database server crash due to unexpected errors and unable to start. There’re currently 3 solutions for this.

Solution 1: Delete files in /var/lib/mysql

Step 1: Check what’s inside /etc/my.cnf. Get the datadir and socket path.

Step 2: Grant permissions first to prevent the issue is caused by lack of access permission. Type the following commands:

chmod -R 777 /var/lib/mysql

Step 3: Delete all files in /var/lib/mysql

rm -rf /var/lib/mysql/*

Step 4: Restart the service

service mysqld restart

Now, you can check the running status of the MySQL server again, it will be in active (running) status if succeed.

Solution 2: Forcing InnoDB Recovery (for emergency situation only)

When serious corruption causes SELECT * FROM tbl_name statements/InnoDB background operations to unexpectedly exit or assert, or even cause InnoDB roll-forward recovery to crash, you can use innodb_force_recovery feature to start the InnoDB storage engine.

To enable innodb_force_recovery, you need to set the value of the parameter greater than 0, which can be from 1-6. For the usage of different value settings please refer to MySQL official documentation for more.

If the issue is caused by the corruption of table space, and the roll-forward recovery fails when restarting, you need to add the following command in /etc/mysql/my.cnf:

[mysqld]

innodb_force_recovery = 6

Then restart MySQL, and export the data with mysqldump. After completion, remove innodb_force_recovery or set it to 0, then recreate the database and import the data.

Bear in mind that this feature can only be used in an emergency situation, and a valuer greater than 3 (which means 4-6) might cause permanent damage to the data files, so it’s highly recommended to test it in the test environment first.

Solution 3: Restart MySQL using backups (most useful)

As is mentioned above, the server failed to start issues can be caused by different issues, and they might not work for you if unlucky. The most effective and reliable solutions would be implementing regular MySQL backups, including full backup and log backup. It is to ensure that there is always a copy of the original corrupted data, so the data loss risk can be minimized and you can always recover important data from the backups.

You can easily backup your mission-critical MySQL databases with Vinchin Backup & Recovery, the all-in-one enterprise backup software with extremely high compatibility. You can backup MySQL 5.5~8.0 in both Windows and Linux servers with a set of features.

1672463054750721.png

Smart backup strategies: Full backup, differential backup, and log backup are all available for you to set your own backup plan on demand. You can set them to run at daily, weekly, or monthly basis.

Database compression: Reduce the size of your database backups by near 70% without consuming CPU of your production environment.

Encrypted transmission: All backup data will be transferred under the safeguard of SSL encryption technique.

Backup storage protection: Prevent MySQL backup in the backup storage from ransomware attacks.

Check here to see how to backup MySQL in 3 steps with Vinchin in detail. You can also manage all the backup jobs via a single web-based console. The software offers a 60-day full-featured free trial, download it today to get the journey started.

Share on:

Categories: Database Tips