Sometimes we starting or when updating XAMPP shows MySQL shutdown unexpectedly error. It should be handled carefully because the data inside the MySQL database is important to us.
Mostly this error occurs due to improper shutdown, corrupted database files, port changes etc,.
Here at Skynats, our server management team will solve any queries regarding your MySQL database servers within a fast time period.
Why did MySQL shutdown unexpectedly?
If you are getting the MySQL shutdown unexpectedly error when starting the XAMPP control panel like below,
This will happen mainly due to corrupted data files in the MySQL data folder and also improper shutdown, missing related files, port change can cause this error.
How To Fix This MySQL shutdown unexpectedly Error ?
- Corrupted Data Files :
First of all, you have to check the MySQL error log for the unexpected shutdown cause. If you are using the XAMPP then you can check the error logs in the “/opt/lampp/var/mysql” location.
From there you can find the unexpected shutdown and so after a clean shutdown, we can remove the redo logs like “.ibd or .ibdata” files. For this you should follow the below steps.
- Rename the mysql data folder /opt/lampp/var/mysql/ to /opt/lampp/var/mysql_bak/.
- Create new folder named /opt/lampp/var/mysql/.
- Copy the /opt/lampp/var/mysql_bak/ content to the /opt/lampp/var/mysql/ folder.
- Copy all the database folders in the /opt/lampp/var/mysql_bak to the new folder excluding the mysql, performance_schema and php myadmin folders.
- Finally you can copy the ibdata1 file from /opt/lampp/var/mysql_bak/ to the /opt/lampp/var/mysql/ folder.
- Start MySQL from XAMPP control panel.
After that we can restart the XAMPP server, it will mostly fix the issue.
2. Change in Configuration :
If the issue still persists after the removal of corrupted data files you need to execute the force recovery of innodb.
In order to do this we need to edit the mysql configuration file in the “/opt/lampp/etc/my.cnf”.
innodb_force_recovery = 1
Also, you need to check the port number of the MySQL updated in the configuration file. You should choose a lower value for InnoDB force recovery as it is relatively safe that only some data on corrupt individual pages will be lost.
Always better to take a backup for database and configuration files for mysql for safety.
If you need any further assistance, our technical team will help you at any time. Contact Us right now.