If you’ve been using XAMPP for some time now, you might have come across an error called “MySQL shutdown unexpectedly”. When you open up your XAMPP controller and try to start your MySQL local server, it simply won’t start and will return this particular error. When this happens, you can’t access your projects in any way. But don’t worry, there’s a solution.
This is a common error reported by many XAMPP users. If you face this error, don’t panic because it has an easy solution. In today’s post, we’re going to tackle one of the most common XAMPP errors MySQL shutdown unexpectedly. So, let’s get started.
Why XAMPP can’t start MySQL?
XAMPP is an amazing tool that you can use to setup your WordPress on localhost. You can work on your project safely and when you’re ready you can transfer your WordPress site from localhost to live server. This will cause no issues on your main site and you can test various plugins and themes safely.
But when you use XAMPP, there is a possibility that you will face many errors. The error that we’re talking about in this post is the MySQL issue where XAMPP mysql won’t start.
When you see this error, where XAMPP MySQL won’t start after you click on the start button, this could be due to many reasons. It might be because of a blocked port, missing dependencies, improper privileges, a crash, or a shutdown by another method. Another reason for this error might be because your MySQL is already running in the background. You can check if this is the case by opening up the task manager (On windows CTRL+Shift+Esc) and closing any MySQL servers that are running.
Sometimes, uninstalling and then reinstalling the MySQL service in XAMPP might fix your error. However, we can still get your projects back by trying another simple method. When you install XAMPP, it already comes with some backup files. You can use these backup files to replace your old ones. But you also have to save your databases so that your website files are not replaced.
If you haven’t used this method before, then follow the steps very closely. It would also be wise to have a backup copy of the mysql folder found in the C:\xampp directory. In the next part of this tutorial, we’ll show you which folder to backup.
Get Latest Post Notifications!
How to solve Error: MySQL shutdown unexpectedly
Before getting started, you should backup your mysql folder in case anything goes wrong. First go to your xampp directory, by default, it will be C:\xampp. Then backup the mysql folder.
Keep a backup copy of this folder somewhere safe in case something goes wrong. Your database will be within this folder, and we’ll be working in this folder. Now open the mysql folder within your xampp directory and follow the steps given below:
Step 1: Rename the ‘data’ folder
When you open up the mysql folder, there will be a folder named ‘data’. Rename it to old_data.
Step 2: Copy backup folder and rename it
You’ll find another folder named “backup”, copy this folder and paste it in the same location. Now you should see another copy of the backup folder named as “backup – Copy”. Rename it to “data”
This folder has all the files that you need for your database. But it still doesn’t have the database of your projects.
Step 3: Copy database files and folders from old_data
Now we’re going to copy all the files and folders from mysql/old_data folder except mysql, performance_schema, and phpmyadmin folders. Take a look at the screenshot for better understanding:
From the image, you can see that we’ve selected all the files and folders, except the 3 folders. Copy all other files and then paste these in the ‘data’ folder.
Step 4: Start MySQL from XAMPP control panel
With that you’ve now solved the error. Now open XAMPP control panel and start the MySQL server and it should start without causing any more error.
That’s it! You’ve solved the error and can now start the MySQL server. Now you can get back to your projects.
Note: This is a temporary solution. The error is caused by the malfunctioning of XAMPP files and not the databases. So after you get access to your project, make sure to backup everything and reinstall XAMPP.
XAMPP allows us to launch our projects on localhost instead of the live server. This allows you to test various projects including WordPress websites. For example, you can send email from WordPress localhost and test if the email function is working perfectly. But some times, you’ll see several errors such as the XAMPP Error 404 where the requested URL isn’t found by the localhost server.
XAMPP has been around for so long, and because of that, most of the errors have easy solutions. So don’t worry if a fix isn’t working, there are so many ways through which you can fix errors. We hope this post was helpful for you and you managed to solve your XAMPP MySQL error. Check out our other posts on WordPress too.
Disclaimer: This post may contain affiliate links and we may receive a small commission if you purchase something by following them. However, we recommend services/products that we believe good to serve your purpose.