How to fix the problem “Error: MySQL shutdown unexpectedly” in XAMPP

When you start MySQL in XAMPP control panel, if there is a blocked port or a corrupted or missing file in MySQL folder, it will trigger MySQL to shutdown.

How to fix the problem “Error: MySQL shutdown unexpectedly” in XAMPP
“Error: MySQL shutdown unexpectedly” in XAMPP
How to fix the problem “Error: MySQL shutdown unexpectedly” in XAMPP

How to fix the problem “Error: MySQL shutdown unexpectedly” in XAMPP

Table of content

About the error in XAMPP

Most developers who work with PHP often use XAMPP in developing PHP projects; websites, etc. They might sometimes experience this issue of mysql shutting down unexpectedly with the errors showing in the log in red colors. They sometimes install new XAMPP and this will erase their entire database

Whenever you receive this error message in your log window in XAMPP, it means that mysql has missing or corrupted files in it. This errors will be fixed if those corrupted files are deleted.

Causes of the problem “Error: MySQL shutdown unexpectedly” in XAMPP

This error is caused by improper database shutdown, a crash, blocked or changes in port, missing files/dependencies, shutdown by another method, improper privileges.

When you start MySQL in XAMPP control panel, if there is a blocked port or a corrupted or missing file in MySQL folder, it will trigger MySQL to shutdown. Thereby displaying the error message in the XAMPP log window like the one in the image below:

Error: MySQL shutdown unexpectedly.
This may be due to a blocked port, missing dependencies, 
improper privileges, a crash, or a shutdown by another method.
Press the Logs button to view error logs and check
the Windows Event Viewer for more clues
If you need more help, copy and post this
entire log window on the forums

How to fix the problem “Error: MySQL shutdown unexpectedly” in XAMPP

How to fix the problem “Error: MySQL shutdown unexpectedly” in XAMPP

In other to fix this problem, follow the steps below

  1. In your XAMPP Cpanel, stop Apache and MySQL and exit XAMPP.
  2. Go to “YourLocalDisk/xampp/mysql/data” folder and rename it to “YourLocalDisk/xampp/mysql/data-backup”. You can also make a backup of this folder.
  3. Create a new folder and give it the name “YourLocalDisk/xampp/mysql/data”.
  4. Go back to the folder we renamed “YourLocalDisk/xampp/mysql/data-backup” and copy only all the folders in it and paste it in “YourLocalDisk/xampp/mysql/data”
  5. Go back again to “YourLocalDisk/xampp/mysql/data-backup” and copy the “ib_logfile0”, “ib_logfile1”, “ibata1”, “aria_log.00000001”, “aria_log_control”, “ib_buffer_pool” and all other log files and paste it in “YourLocalDisk/xampp/mysql/data”
  6. Open your “YourLocalDisk/xampp/mysql/data-backup” folder and copy all the databases in it and paste in “YourLocalDisk/xampp/mysql/data”
  7. You can close the folder window.
  8. Open your XAMPP Cpanel and start MySQL
  9. Also go to phpmyadmin to see if all your database are still intact and complete.

How to fix the problem “Error: MySQL shutdown unexpectedly” in XAMPP

Error Log

2022-11-10 15:07:28 0 [ERROR] InnoDB: Operating system error number 203 in a file operation.
2022-11-10 15:07:28 0 [Note] InnoDB: Some operating system error numbers are described at https://mariadb.com/kb/en/library/operating-system-error-codes/
2022-11-10 15:07:28 0 [ERROR] InnoDB: Could not find a valid tablespace file for ``img_upload`.`images``. Please refer to https://mariadb.com/kb/en/innodb-data-dictionary-troubleshooting/ for how to resolve the issue.
2022-11-10 15:07:28 0 [Warning] InnoDB: Ignoring tablespace for `img_upload`.`images` because it could not be opened.
2022-11-10 15:07:31 0 [Note] InnoDB: 128 out of 128 rollback segments are active.
2022-11-10 15:07:31 0 [Note] InnoDB: Creating shared tablespace for temporary tables
2022-11-10 15:07:31 0 [Note] InnoDB: Setting file 'C:\xampp1\mysql\data\ibtmp1' size to 12 MB. Physically writing the file full; Please wait ...
2022-11-10 15:07:31 0 [Note] InnoDB: File 'C:\xampp1\mysql\data\ibtmp1' size is now 12 MB.
2022-11-10 15:07:31 0 [Note] InnoDB: Waiting for purge to start
2022-11-10 15:07:31 0 [Note] InnoDB: 10.4.11 started; log sequence number 912105400; transaction id 268920
2022-11-10 15:07:31 0 [Note] InnoDB: Loading buffer pool(s) from C:\xampp1\mysql\data\ib_buffer_pool
2022-11-10 15:07:31 0 [Note] Plugin 'FEEDBACK' is disabled.
2022-11-10 15:07:32 0 [Note] Server socket created on IP: '::'.