Are you facing the error "MySQL shutdown unexpectedly"?
This guide will help you.
MySQL shutdown unexpectedly generally occurs due to various reasons such as corrupted files, improper shutdown, port changes.
If this database issue is neglected, the website hosted using it will fail to load.
Here at Ibmi Media, as part of our Server Management Services, we regularly help our Customers to fix MySQL related errors.
In this context, we shall look into the steps to fix this MySQL error.
What triggers the error "MySQL shutdown unexpectedly"?
MySQL is the most widely adopted open source relational database and is the primary relational data store for popular websites and applications.
In most cases, running MySQL sometimes ends in errors such as MySQL shutdown unexpectedly.
The error usually shows up when the customer runs MySQL in a webserver. Corrupted files in the mysql/data folder are the reason for the error.
Similarly, port change, improper shutdown, missing related files, etc can lead to the same error.
How we fix the error MySQL shutdown unexpectedly?
In order to fix this MySQL error, simply follow the following tips;
1. Irregular files
Begin by checking for corrupted files in the MySQL folder.
For instance, in the XAMPP server, navigate to C:\xampp\mysql\data folder.
Then we look for redo log files. This file indicates an unexpected shutdown. So, after a clean shutdown, we delete the redo logs( .ibd or .ibdata files).
Finally, we restart the XAMPP server. In most cases, this fixes the error.
2. Configuration changes
Sometimes, the removal of corrupted files cannot resolve the error. Executing a force recovery of InnoDB can fix this issue.
To do this, simply open the MySQL config file. Here we add the code under the mysqld section.
innodb_force_recovery = 1
Similarly, you can check the MySQL port number updated in the configuration file. It is recommended to choose lower values for InnoDB force recovery as it is relatively safe that only some data on corrupt individual pages will be lost.
In the same vain, it is good to always take enough backup prior to the configuration changes to prevent data loss at any cost.