Have you ever tried to start MySQL in XAMPP and been hit with the frustrating “MySQL shutdown unexpectedly” error? Don’t worry, you are not alone in facing this problem, and the fixing process is easier than you think!
In this post, I will explain why this problem occurs and how to fix it step-by-step with examples to make it super clear for you. Let’s get started.
Why does the “MySQL Shutdown Unexpectedly” Error Happen?
The error can occur when MySQL cannot start properly in XAMPP. The common two reasons for this are:
1. Port Number Conflict
MySQL and any other database server programs (or even another MySQL server) use the same port number. Since one program can use a port number at a time, this creates a conflict between them and stop MySQL from running.
Example: Let’s say MySQL server is set to use port number 3306, and another application (e.g., Skype or another database server) is also using port number 3306. In this situation, MySQL will not start because the same port number is already used by another program or already take2n.
2. XAMPP Blocking the Port
Sometimes, XAMPP itself blocks MySQL’s port. It usually happens due to leftover lock files, misconfigurations, or a crashed MySQL process. This happens when XAMPP cannot connect properly MySQL to its default port.
Example: If your MySQL crashed unexpectedly in the past, and XAMPP is now trying to access the same port number 3306. But because of leftover crash files or a misconfigured setup, it keeps blocking access.
3. Insufficient Permission
If XAMPP doesn’t have the right permissions to access certain files or folders required by MySQL, it may block MySQL from running and the error occurs.
Example: You installed XAMPP in a folder like C:/Program Files instead of C:/xampp, and Windows’ security settings are preventing XAMPP from modifying files in that directory.
Now you may know how does the error happens, and I hope you will try to not do such things to avoid from the error.
How to fix it? Step by step guide
Step 1: Open your XAMPP control panel and click on the Config of the module MySQL, where you are getting an error, then click on my.ini
.

Step 2: Search for port=3306
and change it to port=3307
. If your port is already 3307, then upgrade by 1, which is 3308. And finally, save this file by clicking File>Save or you can use the shortcut also to save it, for Windows Ctrl + S and for Mac Cmd+S.

Step 3: Now, click on the Explorer of the XAMPP Control Panel. It redirects you to the File Explorer on C://xampp
(where your XAMPP is installed) location. Then, search for phpMyAdmin and click on that. It opens the files and folders inside phpMyAdmin, then searches for config.inc. Most importantly, open the config.inc file in Notepad (click on config.inc just for one, then right-click on the mouse, then click on Open with and search for Notepad software, and then click on that).

Step 4: In step 4, search for, /* Bind to the localhost ipv4 address and tcp */
, then remove the last line, which is a black overlap in the given picture below. Then, add a new line as shown in the picture. Make sure you have added the port number that you entered earlier; in my case, I have added 3307. Also, don’t make any typological error on this. So, please verify the line you have added to make sure you have made no errors. Finally, save this file by clicking File>Save, or you can use the shortcut also to save it: for Windows, Ctrl + S, and for Mac, Cmd + S.

Step 5: Finally, you have completed all your tasks to solve the error. Now, close the Xampp Control Panel and reopen it. Now, you won’t see the error because we have solved your error.

Here, you can see the MySQL module is running in Xampp Control Panel without any error. Congrats to you.