How to fix Error: MySQL shutdown unexpectedly in XAMPP

Updated by shortbuzz

Xampp error windows

In this article, we’ll explain how to solve "Error: MySQL shutdown unexpectedly" with an easy method.

MySQL shutdown unexpectedly error held because file corruption while quiting the xampp you may got this error: Cannot create file xampp-control.ini Access is denied first you need to fix this error not come in future so when you fix this error first then you won't get error: MySQL shutdown unexpectedly in future, let's fix "Cannot create file Access is denied" error first.

In order to prevent future occurrences of the error: MySQL shutdown unexpectedly, which is caused by file corruption, you must first resolve the Cannot create file xampp-control.ini Access is denied error. Let's address "Error: Cannot create file xampp-control.ini Access is denied" error first in order to prevent future occurrences of the "error: MySQL shutdown unexpectedly."

Error: Cannot create file xampp-control.ini, Access Denied - Xampp

  1. Right-click on "Xampp control panel shortcut" and click on "Properties" now dialog box open
  2. Goto Compatibility tab and find "Run this program as an administrator"
  3. Check the box "Run as administrator" and then click "ok" button and then click "apply" button in the dialog box and click "ok" button.

In this blog post, we will resolve the "xampp-control.ini Access is denied" XAMPP server problem. The xampp control panel will run as administrator when you start it.

You can also start the xampp panel by selecting "Run as administrator" every time you open it. If you don't want to follow the above instructions, keep in mind that you should always run the xampp panel as administrator everytime you open it, otherwise you will always get these two errors "Cannot create file xampp-control.ini, Access Denied" and "MySQL shutdown unexpectedly. This may be due to a blocked port, missing dependencies"

To avoid this error in the future, always run the xampp panel as "Run as administrator."

We recently discovered that shutting down MySQL without running XAMPP as an administrator frequently leads to corruption, so now we need to fix the common issue of "MySQL shutdown unexpectedly error" using the method given below.

How to fix MySQL shutdown unexpectedly error

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

Many developers are encountering this problem repeatedly; even after it has been resolved, problems return after some time, and they keep visiting stackoverflow and finding the answer, but their solution is really giving them headaches every time, so today we are showing a very simple method to fix this error immediately.

Step 1: Run xampp control panel as administrator

Open xampp control panel with Run as administrator

Step 2: Find and open shell on xampp-control panel

Find Shell on the right side and click to open the window shown below.

Setting environment for using XAMPP for Windows.
User@WINDOWS-VY9FS06 c:\xampp
#

Step 3: Change directory to the mysql folder

Using the command cd mysql, change directory to the mysql folder.

Step 4: Rename "data" folder to "data_old"

After opening the mysql folder, use the command rename data data_old to rename the data folder within the mysql folder.

Step 5: Make new copy of "backup" folder to "backup_data" folder

Using the command xcopy backup backup_data /e /i /h, create a fresh copy of the backup folder after renaming the data folder to data_old.

Step 6: Rename the "backup_data" folder to the data folder

After making a fresh copy of the backup folder to the backup_data folder, use the command rename backup_data data to rename the backup_data folder to the data folder.

Step 7: All files in the "data_old" folder should be copied to the "data" folder to restore database

Now your MySQL will work, but your database will be unavailable in phpmyadmin. To restore your database, copy all files from the "data_old" folder and paste them into your new "data" folder. To do this, run the command on shell xcopy data_old\* data\ /e /i /h

Step 8: In xampp control panel start the mysql

Now, go to the XAMPP control panel and click to start mysql; the problem has been fixed, and it is running with a success message.

The complete code to resolve the error "xampp mysql shutdown unexpectedly this may be due to a blocked port, missing dependencies" is provided below.

Setting environment for using XAMPP for Windows.
    User@WINDOWS-VY9FS06 c:\xampp
    # cd mysql
    
    User@WINDOWS-VY9FS06 c:\xampp\mysql
    # rename data data_old
    
    User@WINDOWS-VY9FS06 c:\xampp\mysql
    # xcopy backup backup_data /e /i /h
    backup\aria_log.00000001
    backup\aria_log_control
    backup\ibdata1
    backup\ibtmp1
    backup\ib_buffer_pool
    backup\ib_logfile0
    backup\ib_logfile1
    backup\multi-master.info
    backup\my.ini
    backup\mysql\columns_priv.frm
    backup\mysql\columns_priv.MAD
    backup\mysql\columns_priv.MAI
    backup\mysql\column_stats.frm
    backup\mysql\column_stats.MAD
    backup\mysql\column_stats.MAI
    backup\mysql\db.frm
    backup\mysql\db.MAD
    backup\mysql\db.MAI
    backup\mysql\event.frm
    backup\mysql\event.MAD
    backup\mysql\event.MAI
    backup\mysql\func.frm
    backup\mysql\func.MAD
    backup\mysql\func.MAI
    backup\mysql\general_log.CSM
    backup\mysql\general_log.CSV
    backup\mysql\general_log.frm
    backup\mysql\global_priv.frm
    backup\mysql\global_priv.MAD
    backup\mysql\global_priv.MAI
    backup\mysql\gtid_slave_pos.frm
    backup\mysql\gtid_slave_pos.ibd
    backup\mysql\help_category.frm
    backup\mysql\help_category.MAD
    backup\mysql\help_category.MAI
    backup\mysql\help_keyword.frm
    backup\mysql\help_keyword.MAD
    backup\mysql\help_keyword.MAI
    backup\mysql\help_relation.frm
    backup\mysql\help_relation.MAD
    backup\mysql\help_relation.MAI
    backup\mysql\help_topic.frm
    backup\mysql\help_topic.MAD
    backup\mysql\help_topic.MAI
    backup\mysql\index_stats.frm
    backup\mysql\index_stats.MAD
    backup\mysql\index_stats.MAI
    backup\mysql\innodb_index_stats.frm
    backup\mysql\innodb_index_stats.ibd
    backup\mysql\innodb_table_stats.frm
    backup\mysql\innodb_table_stats.ibd
    backup\mysql\plugin.frm
    backup\mysql\plugin.MAD
    backup\mysql\plugin.MAI
    backup\mysql\proc.frm
    backup\mysql\proc.MAD
    backup\mysql\proc.MAI
    backup\mysql\procs_priv.frm
    backup\mysql\procs_priv.MAD
    backup\mysql\procs_priv.MAI
    backup\mysql\proxies_priv.frm
    backup\mysql\proxies_priv.MAD
    backup\mysql\proxies_priv.MAI
    backup\mysql\roles_mapping.frm
    backup\mysql\roles_mapping.MAD
    backup\mysql\roles_mapping.MAI
    backup\mysql\servers.frm
    backup\mysql\servers.MAD
    backup\mysql\servers.MAI
    backup\mysql\slow_log.CSM
    backup\mysql\slow_log.CSV
    backup\mysql\slow_log.frm
    backup\mysql\tables_priv.frm
    backup\mysql\tables_priv.MAD
    backup\mysql\tables_priv.MAI
    backup\mysql\table_stats.frm
    backup\mysql\table_stats.MAD
    backup\mysql\table_stats.MAI
    backup\mysql\time_zone.frm
    backup\mysql\time_zone.MAD
    backup\mysql\time_zone.MAI
    backup\mysql\time_zone_leap_second.frm
    backup\mysql\time_zone_leap_second.MAD
    backup\mysql\time_zone_leap_second.MAI
    backup\mysql\time_zone_name.frm
    backup\mysql\time_zone_name.MAD
    backup\mysql\time_zone_name.MAI
    backup\mysql\time_zone_transition.frm
    backup\mysql\time_zone_transition.MAD
    backup\mysql\time_zone_transition.MAI
    backup\mysql\time_zone_transition_type.frm
    backup\mysql\time_zone_transition_type.MAD
    backup\mysql\time_zone_transition_type.MAI
    backup\mysql\transaction_registry.frm
    backup\mysql\transaction_registry.ibd
    backup\mysql\user.frm
    backup\performance_schema\db.opt
    backup\phpmyadmin\db.opt
    backup\phpmyadmin\pma__bookmark.frm
    backup\phpmyadmin\pma__bookmark.ibd
    backup\phpmyadmin\pma__central_columns.frm
    backup\phpmyadmin\pma__central_columns.ibd
    backup\phpmyadmin\pma__column_info.frm
    backup\phpmyadmin\pma__column_info.ibd
    backup\phpmyadmin\pma__designer_settings.frm
    backup\phpmyadmin\pma__designer_settings.ibd
    backup\phpmyadmin\pma__export_templates.frm
    backup\phpmyadmin\pma__export_templates.ibd
    backup\phpmyadmin\pma__favorite.frm
    backup\phpmyadmin\pma__favorite.ibd
    backup\phpmyadmin\pma__history.frm
    backup\phpmyadmin\pma__history.ibd
    backup\phpmyadmin\pma__navigationhiding.frm
    backup\phpmyadmin\pma__navigationhiding.ibd
    backup\phpmyadmin\pma__pdf_pages.frm
    backup\phpmyadmin\pma__pdf_pages.ibd
    backup\phpmyadmin\pma__recent.frm
    backup\phpmyadmin\pma__recent.ibd
    backup\phpmyadmin\pma__relation.frm
    backup\phpmyadmin\pma__relation.ibd
    backup\phpmyadmin\pma__savedsearches.frm
    backup\phpmyadmin\pma__savedsearches.ibd
    backup\phpmyadmin\pma__table_coords.frm
    backup\phpmyadmin\pma__table_coords.ibd
    backup\phpmyadmin\pma__table_info.frm
    backup\phpmyadmin\pma__table_info.ibd
    backup\phpmyadmin\pma__table_uiprefs.frm
    backup\phpmyadmin\pma__table_uiprefs.ibd
    backup\phpmyadmin\pma__tracking.frm
    backup\phpmyadmin\pma__tracking.ibd
    backup\phpmyadmin\pma__userconfig.frm
    backup\phpmyadmin\pma__userconfig.ibd
    backup\phpmyadmin\pma__usergroups.frm
    backup\phpmyadmin\pma__usergroups.ibd
    backup\phpmyadmin\pma__users.frm
    backup\phpmyadmin\pma__users.ibd
    backup\test\db.opt
    137 File(s) copied
    
    User@WINDOWS-VY9FS06 c:\xampp\mysql
    # rename backup_data data
    
    User@WINDOWS-VY9FS06 c:\xampp\mysql
    # xcopy data_old\* data\  /e /i /h
    Overwrite C:\xampp\mysql\data\aria_log.00000001 (Yes/No/All)? a
    data_old\aria_log.00000001
    data_old\aria_log_control
    data_old\ibdata1
    data_old\ibtmp1
    data_old\ib_buffer_pool
    data_old\ib_logfile0
    data_old\ib_logfile1
    data_old\multi-master.info
    data_old\my.ini
    data_old\mysql.pid
    data_old\mysql_error.log
    data_old\mysql\columns_priv.frm
    data_old\mysql\columns_priv.MAD
    data_old\mysql\columns_priv.MAI
    data_old\mysql\column_stats.frm
    data_old\mysql\column_stats.MAD
    data_old\mysql\column_stats.MAI
    data_old\mysql\db.frm
    data_old\mysql\db.MAD
    data_old\mysql\db.MAI
    data_old\mysql\event.frm
    data_old\mysql\event.MAD
    data_old\mysql\event.MAI
    data_old\mysql\func.frm
    data_old\mysql\func.MAD
    data_old\mysql\func.MAI
    data_old\mysql\general_log.CSM
    data_old\mysql\general_log.CSV
    data_old\mysql\general_log.frm
    data_old\mysql\global_priv.frm
    data_old\mysql\global_priv.MAD
    data_old\mysql\global_priv.MAI
    data_old\mysql\gtid_slave_pos.frm
    data_old\mysql\gtid_slave_pos.ibd
    data_old\mysql\help_category.frm
    data_old\mysql\help_category.MAD
    data_old\mysql\help_category.MAI
    data_old\mysql\help_keyword.frm
    data_old\mysql\help_keyword.MAD
    data_old\mysql\help_keyword.MAI
    data_old\mysql\help_relation.frm
    data_old\mysql\help_relation.MAD
    data_old\mysql\help_relation.MAI
    data_old\mysql\help_topic.frm
    data_old\mysql\help_topic.MAD
    data_old\mysql\help_topic.MAI
    data_old\mysql\index_stats.frm
    data_old\mysql\index_stats.MAD
    data_old\mysql\index_stats.MAI
    data_old\mysql\innodb_index_stats.frm
    data_old\mysql\innodb_index_stats.ibd
    data_old\mysql\innodb_table_stats.frm
    data_old\mysql\innodb_table_stats.ibd
    data_old\mysql\plugin.frm
    data_old\mysql\plugin.MAD
    data_old\mysql\plugin.MAI
    data_old\mysql\proc.frm
    data_old\mysql\proc.MAD
    data_old\mysql\proc.MAI
    data_old\mysql\procs_priv.frm
    data_old\mysql\procs_priv.MAD
    data_old\mysql\procs_priv.MAI
    data_old\mysql\proxies_priv.frm
    data_old\mysql\proxies_priv.MAD
    data_old\mysql\proxies_priv.MAI
    data_old\mysql\roles_mapping.frm
    data_old\mysql\roles_mapping.MAD
    data_old\mysql\roles_mapping.MAI
    data_old\mysql\servers.frm
    data_old\mysql\servers.MAD
    data_old\mysql\servers.MAI
    data_old\mysql\slow_log.CSM
    data_old\mysql\slow_log.CSV
    data_old\mysql\slow_log.frm
    data_old\mysql\tables_priv.frm
    data_old\mysql\tables_priv.MAD
    data_old\mysql\tables_priv.MAI
    data_old\mysql\table_stats.frm
    data_old\mysql\table_stats.MAD
    data_old\mysql\table_stats.MAI
    data_old\mysql\time_zone.frm
    data_old\mysql\time_zone.MAD
    data_old\mysql\time_zone.MAI
    data_old\mysql\time_zone_leap_second.frm
    data_old\mysql\time_zone_leap_second.MAD
    data_old\mysql\time_zone_leap_second.MAI
    data_old\mysql\time_zone_name.frm
    data_old\mysql\time_zone_name.MAD
    data_old\mysql\time_zone_name.MAI
    data_old\mysql\time_zone_transition.frm
    data_old\mysql\time_zone_transition.MAD
    data_old\mysql\time_zone_transition.MAI
    data_old\mysql\time_zone_transition_type.frm
    data_old\mysql\time_zone_transition_type.MAD
    data_old\mysql\time_zone_transition_type.MAI
    data_old\mysql\transaction_registry.frm
    data_old\mysql\transaction_registry.ibd
    data_old\mysql\user.frm
    data_old\performance_schema\db.opt
    data_old\phpmyadmin\db.opt
    data_old\phpmyadmin\pma__bookmark.frm
    data_old\phpmyadmin\pma__bookmark.ibd
    data_old\phpmyadmin\pma__central_columns.frm
    data_old\phpmyadmin\pma__central_columns.ibd
    data_old\phpmyadmin\pma__column_info.frm
    data_old\phpmyadmin\pma__column_info.ibd
    data_old\phpmyadmin\pma__designer_settings.frm
    data_old\phpmyadmin\pma__designer_settings.ibd
    data_old\phpmyadmin\pma__export_templates.frm
    data_old\phpmyadmin\pma__export_templates.ibd
    data_old\phpmyadmin\pma__favorite.frm
    data_old\phpmyadmin\pma__favorite.ibd
    data_old\phpmyadmin\pma__history.frm
    data_old\phpmyadmin\pma__history.ibd
    data_old\phpmyadmin\pma__navigationhiding.frm
    data_old\phpmyadmin\pma__navigationhiding.ibd
    data_old\phpmyadmin\pma__pdf_pages.frm
    data_old\phpmyadmin\pma__pdf_pages.ibd
    data_old\phpmyadmin\pma__recent.frm
    data_old\phpmyadmin\pma__recent.ibd
    data_old\phpmyadmin\pma__relation.frm
    data_old\phpmyadmin\pma__relation.ibd
    data_old\phpmyadmin\pma__savedsearches.frm
    data_old\phpmyadmin\pma__savedsearches.ibd
    data_old\phpmyadmin\pma__table_coords.frm
    data_old\phpmyadmin\pma__table_coords.ibd
    data_old\phpmyadmin\pma__table_info.frm
    data_old\phpmyadmin\pma__table_info.ibd
    data_old\phpmyadmin\pma__table_uiprefs.frm
    data_old\phpmyadmin\pma__table_uiprefs.ibd
    data_old\phpmyadmin\pma__tracking.frm
    data_old\phpmyadmin\pma__tracking.ibd
    data_old\phpmyadmin\pma__userconfig.frm
    data_old\phpmyadmin\pma__userconfig.ibd
    data_old\phpmyadmin\pma__usergroups.frm
    data_old\phpmyadmin\pma__usergroups.ibd
    data_old\phpmyadmin\pma__users.frm
    data_old\phpmyadmin\pma__users.ibd
    data_old\xyzdatabase@002dmy_table\user_accounts.frm
    data_old\xyzdatabase@002dmy_table\user_accounts.ibd
    data_old\xyzdatabase@002dmy_table\category.frm
    data_old\xyzdatabase@002dmy_table\category.ibd
    data_old\xyzdatabase@002dmy_table\post.frm
    data_old\xyzdatabase@002dmy_table\post.ibd
    data_old\xyzdatabase@002dmy_table\subcategory.frm
    data_old\xyzdatabase@002dmy_table\subcategory.ibd
    data_old\test\db.opt
    148 File(s) copied
    
    User@WINDOWS-VY9FS06 c:\xampp\mysql
    #

Now launch the XAMPP control panel and start MySQL.

Summary

If you already facing XAMPP Error: MySQL shutdown unexpectedly you need to fix this error first and then you always run the xampp panel as "Run as administrator" otherwise you keep getting this error in future.

Also by fixing "MySQL shutdown unexpectedly error" also fixed "Cannot create file xampp-control.ini access denied" error

if you don't run the xamp as administrator then when you existing xampp file get corrupted and you keep get these errors "Cannot create file “C:\xampp\xampp-control.ini” Access is denied" and "Exception EAccessViolation in module xampp-control.exe at 0025B2AE"

And then when you next time open xampp and you again get "MySQL shutdown unexpectedly" error and your mysql won't start and keep searching on internet and stackoverflow and some of articles says to change port number, no that's not the issue so don't forget to run the xampp as administrator everything will be fine and you won't get this headache issue again.

You can fix these issues with an easy method.

  1. Always run XAMPP as "Run as administrator" to avoid any errors in the future.
  2. Rename the data folder to data_old folder inside xampp>mysql folder
  3. Make a copy of xampp>mysql>backup folder as backup_data
  4. Rename backup_data folder as data folder
  5. Copy all files inside data_old folder into data folder to restore database
  6. Start MySQL from the XAMPP control panel and your problem fixed.

And it's finished. No databases were lost, no ports had to be changed, no need to stop the mysqld process, no need to restore from an earlier version, and no issues occurred again.

More articles from shortbuzz

ecommece template tailwindcss text and businessman
Technology

Get Free TailwindCSS eCommerce Template: Build Online Store

TailwindCSS eCommerce template free: Take advantage of our template & boost your online store's sales with a visually stunning and user-friendly website design continue reading

OpenAI logo chatgpt
Technology

How to block ChatGPT from access the content of your website

By adding code to robots.txt, .htaccess or Nginx server, you can stop ChatGPT from access or crawl your website content that is being used for AI training data continue reading

Google sign-in button and Google logo
Technology

How to migrate from Google Sign-In API to Identity Services

Use Google Identity Services API to improve the user experience & security of your website. Replace old Google Sign-In API with new method: Full migration guide continue reading

flower with cards
Technology

TailwindCSS: Show More/Less Truncate Text using JS & Reactjs

Use TailwindCSS, JavaScript or ReactJS to create a read more & show less function with a smooth transition using tailwind multi-line-clamp truncation continue reading

Convert Number to Words
Technology

Convert Number to Words using Javascript, Jquery, ReactJS

Code and output for Convert number to words using JQuery, ReactJS, JavaScript, and TypeScript. Example: convert 1 to one continue reading

cloud server with laptop
Technology

Best web hosting service provider in Saudi Arabia (KSA)

Find the best web hosting service providers for your company in Saudi Arabia. Our detailed list includes the most cost-effective, reliable, and fast options. continue reading

Web hosting server and cloud hosting server
Technology

What is Web Hosting and Types: A Complete Beginners Guide

For creation of websites requires web hosting. Learn about many types and their advantages and disadvantages to select the best option for your website. continue reading

Using tailwind css align item in the centre of the screen text and tailwind logo
Technology

Tailwind CSS center div vertically and horizontally

Using tailwindCSS, place the div in the middle of the screen, both vertically and horizontally, using flexbox or grid system with simple explanation. continue reading

Bootstrap icon and Tailwind css icon and grid layout design
Technology

How to make Tailwind CSS grid system like Bootstrap grids

Tailwind offers grid-template-column utility for creating basic grids, as well as the grid-cols-{size} & col-span-{size} utilities to create bootstrap-like grid continue reading

Python logo with folder icon and python code on computer screen in the background
Technology

Python Check If File Exists - Python Check If Directory Exists?

path.exists(path) method in python is used to check if a given file or directory exists or not; if it exists, it returns true or else return False continue reading