Why does MySQL shutdown unexpectedly?

It is necessary to stop MySQL before exiting XAMPP. If you exit XAMPP without stopping MySQL, it may corrupt the MySQL data files. Due to this, you may experience several problems with MySQL, like the shutting down of MySQL unexpectedly. If you are experiencing such a problem, it might be possible that the MySQL data files on your system are corrupted. We have described some troubleshooting methods that may help you get rid of this problem.

Error: MySQL shutdown unexpectedly

Try the following solutions to fix the issue. Before you proceed, we recommend you create a backup of the XAMPP folder. For this, copy the XAMPP folder and paste it into another partition of your hard drive or your external hard drive. Let’s see all these solutions in detail. Before trying every method written below, make sure that you have closed XAMPP properly.

1] Launch XAMPP as administrator

It is recommended to always launch XAMPP as an administrator to avoid data file corruption. Launch XAMPP as administrator and see if it fixes the problem. If this helps, you will save time on other troubleshooting methods. To launch XAMPP as administrator, follow the steps below: You can also set XAMPP to always run as administrator.

2] Repair MySQL Database

As described above in this article, the main cause of this problem is the corruption in XAMPP data files. If the problem is occurring on your computer due to this issue, repairing the MySQL database can fix the issue. The steps to repair the MySQL database are given below: Click on Windows Search and type PowerShell. Select Windows PowerShell from the Search Results. Type the following command and press Enter. The above command will start the MySQL server without loading the grant tables. When the above command is executed successfully, type the following command and press Enter. The above command will repair the MySQL database. After the above commands are executed successfully, check if the issue persists.

3] Modify the my.ini file

Changing the port by modifying the my.ini file has fixed the issue for some users. You can also try this. Open the my.ini file and change the port 3306 to something else. By default, the my.ini file is located at the following location:

If you do not find the my.ini file at the above-mentioned location, you can follow the instructions mentioned below.

After opening the my.ini file in Notepad, press the Ctrl + F keys and type 3306. Replace any of the 3306 ports with a different port number. You can enter any random port number, like 3307, 3308, etc. For some users, replacing the 3306 port with 2811 fixed the issue. Save the my.ini file and close Notepad. Restart your computer and then launch XAMPP. Check if the issue is fixed. If this does not work, revert the changes that you have made in the my.ini file and try the next solution.

4] Delete all the files inside the Data folder

If the above solution did not fix your problem, revert the changes in the my.ini file that you have just made. Now, open the File Explorer and go to the following path:

The above path opens the Data folder directly. Now, delete all the files except the folders. After deleting the files inside the Data folder, go to the following path in File Explorer:

Locate the my.ini file and open it with Notepad. Now, type port=8111 just below port=3306 (as shown in the screenshot above). Press the Ctrl + S keys to save the changes you made in the my.ini file and close Notepad. Now, run XAMPP as administrator and start MySQL. The problem should not occur this time.

5] Rename the aria_log_control file

If the above solution did not fix your problem, Open the XAMPP folder that you copied on your external hard drive or on another hard drive partition and copy all the contents inside it. Now, open the XAMPP on your C drive and paste the copied content there. Replace the files and folders if you will be asked to do so. Now, go to the following path:

Rename aria_log_control to aria_log_control_old and launch XAMPP. Start MySQL and see if this brings any changes. If this does not help, revert the changes and try the next solution. Read: Best free Xampp Server alternatives for developers.

6] Stop all the SQL services and start them again

Restarting the SQL services has fixed the issue of some users. This method may work for you too. Open the Services app and stop all the SQL services and start them again. The steps to do this are written below:

After restarting the SQL services, close the Services app and launch XAMPP as administrator. Start MySQL and see if the error occurs again.

7] Copy the files from the Backup folder to the Data folder

Another effective solution to fix this problem is to copy all the data inside the Backup folder and paste it into the Data folder. To do so, first, copy the below path and paste it into the address bar of the File Explorer. After that press Enter. This will open the Backup folder of XAMPP in your C directory. Now, copy all the data from there and go to the following path: Paste the copied data there. If you are prompted to replace the files, select Yes. Launch XAMPP as administrator and check if you can start MySQL this time. If not, try the next solution.

8] Delete the INFO file(s) from the Data folder

If the problem still persists, delete the INFO file and check if it helps. The INFO file(s) is/are located at the following location on your C drive.

Whether there is one or more than one INFO file at the above location, you have to delete all of them. After deleting the INFO file(s), launch XAMPP and start MySQL. MySQL should start without giving any error. If this does not work, copy all the files from the XAMPP folder that you have created as a backup on your external hard drive or on another hard drive partition and paste the copied files inside the XAMPP folder on your C drive. Replace the files and folders if you are asked to do so.

9] Rename the Data folder and copy the ibdata1 file to the Data folder

This solution has helped a lot of users. If the above solutions did not fix your problem, this method should work for you. Rename the Data folder and copy the ibdata1 file to the Data folder. The process to do this is explained below.

10] Uninstall and reinstall XAMPP

If all the above solutions failed to fix your problem, uninstall and reinstall XAMPP. You can uninstall XAMPP from the Control Panel or from Windows 11/10 Settings. After uninstalling Xampp, download its latest version from the official website of Apache and install it again. Read: How to increase phpMyAdmin upload size on XAMPP.

What to do if MySQL is not opening in XAMPP?

You may experience problems with XAMPP if you install it in another location instead of its default location. The default location to install XAMPP is c:\xampp. Therefore, if you have installed XAMPP on another location, uninstall it and install it on its default location. If you have installed XAMPP on its default location but still MySQL is not opening or running in XAMPP, open the Services app in Windows 11/10 and stop all SQL services and start them again. Another effective solution to fix this problem is to change the port 3306 to 3308. To do this, you have to edit the my.ini file, which is located at the following location: Hope this helps. Read next: Apache is not starting from XAMPP Control Panel in Windows 11/10.

Error  MySQL shutdown unexpectedly  Fixed  - 84Error  MySQL shutdown unexpectedly  Fixed  - 49