Z.com Philippines logo represents the brand identity.
November 28, 2023
6 min Read
Flona

5 Effective Ways to Fix the Error: MySQL Shutdown Unexpectedly

Sometimes, you may open WordPress to modify or manage your website, only to find that it cannot connect to the database. This issue arises because MySQL has unexpectedly shut down.

 

This error is quite common and often occurs when using a local development environment, especially with XAMPP, particularly when reinstalling it. You can fix this issue through various methods, but our focus will be on the XAMPP control panel, which provides the easiest solution through its user-friendly interface.

 

In this blog, we will explore XAMPP, understand the error and its causes, and then discuss the fixes to easily address the problem. 

What is XAMPP?

XAMPP is an open-source live server developed by Apache Friends. If you enjoy creating websites and apps using PHP programs, you might need either WAMPP or XAMPP. While the former is exclusive to Windows, the latter is compatible with both Windows and Linux.

 

XAMPP stands for Cross-platform (X), Apache (A), MariaDB (M), PHP (P), and Perl (P). It is popular due to the variety of software in its bundle. Each local environment has a unique bundle, but XAMPP offers one of the best and most versatile options. It assists developers in testing and deploying websites and applications with ease.

 

As a free source, you can easily find the link online and download it without any hassle. You can even choose to download specific components from its bundle rather than installing the entire package. In addition to its simple installation, XAMPP comes with a control panel that lets you access the settings and logs of each component.

What Does the Error: MySQL Shutdown Unexpectedly Mean?

This error occurs when the MySQL software stops functioning without being manually closed. As a result, your WordPress site shuts down because the MySQL software cannot establish a stable connection with the database.

How Does the Error Occur?

Typically, the MySQL software may shut down unexpectedly due to reinstalling XAMPP. However, other reasons may also contribute to the issue, as described below:

 

      Corrupted MySQL Configuration File - The MySQL configuration file might be corrupt, leading to unexpected errors.

      MySQL Service is Down - MySQL service may not be running on your system due to specific permissions.

      Shared Port - The port connected to the MySQL software may be shared with another program, causing confusion for the system and ultimately leading to an error.

How to Fix the Error: MySQL Shutdown Unexpectedly?

To address this issue, you can employ five different methods. We will examine each of them to help you resolve the problem effectively.

1.   Use Root Privileges

XAMPP is designed to work best with administrator access which is why you might face a few errors if you do not have the necessary permissions. This is because you cannot play much around with it if you do not have root privileges. There are some components and functions that only work with the root user.

 

Hence, you must activate the root privileges to mitigate this error. Here is how,

  1. Close XAMPP and head to the folder where it is installed.
  2. Locate the xampp-control file.
  3. Right-click on it and look for the Run as administration option. Tap on it.

2.   Restore Your Backup

If accessing the panel as an administrator does not work, then it is time to restore the backup files. The great thing about XAMPP is that it automatically creates a thread of backup files of your local development environment’s software. This backup goes straight to the place where XAMPP is installed.

 

Here is how you can access these files,

  1. Go to My Computer and do a quick search for XAMPP.

  1. There, you will find MySQL.

  1. Inside this folder, look for two different folders, data and backup.

  1. Stop the MySQL service from the panel to create a backup.

  1. Make a copy of the data folder. Rename it.
  2. Copy the contents of the backup folder to the data folder.
  3. Keep the old data folder until you can ensure that the error has been mitigated and everything is running smoothly.
  4. Restart the MySQL service.

 

3.   Terminate the MySQL Service

This method is usually saved for the last. However, you might need its help with other methods as well. So, if other solutions do not work out for you, then you can come back to this fix. Here is how to terminate the service manually;

 

  1. Press Windows + R to open the Run application.
  2. Type in "services.msc" and press Enter. A pop-up will open.

  1. Scroll in the list to find MySQL service.
  2. Press right-click on it and search for Stop. Tap on it to terminate the service.

4.   Shift to a Different Port

A common misunderstanding behind the MySQL shutdown is that another software may be using the same port as MySQL. This confusion can lead the service to terminate unexpectedly and cause an error. A shared port won’t be solved by shifting to the root privileges or by creating a backup. You need a different solution.

 

By default, the port is set to 3306. To check if this is the port, go to the XAMPP panel and find Netstat.

 

 

This will show you all the active connections, their designated ports, and the service attached to these ports. Search for MySQL to know which of the ports the service is using and whether it is the default port.

 

First, you need to terminate the MySQL service. Here is how,

 

  1. Press Windows + R to open the Run application.
  2. Type in "services.msc" and press Enter. A pop-up will open.

  1. Scroll in the list to find MySQL service.
  2. Press right-click on it and search for Stop. Tap on it to terminate the service.

 

Now that you have terminated the service, here is what you need to do next,

 

  1. Now, get back to the XAMPP panel and search for Config.

  1. Tap on the my.ini button.
  2. You might be asked to pick a text editor. Pick anyone that you are comfortable with. 
  3. Check for the word Port that specifies which port MySQL is using.
  4. Change the port number to a port number that other applications or services are not using. Usually, 3307 is recommended as it is mostly available.

  1. Hit the Save button and close the file.
  2. Once that is done, open the XAMPP panel and restart the MySQL service. If this does not work, try using a different port.

5.   Repair the MySQL Database

You can also try repairing the MySQL database manually. Here is what you need to do,

  1. Power up the XAMPP panel.
  2. Click on the Shell button to open the Shell editor.

  1. Enter the following command into the line to start up MySQL.

  1. Once that is done, go to the panel and open another Shell window again from the panel.
  2. Repair the database using the following command.

  1. Go to the first Shell window and stop MySQL.
  2. Close both of the Shell windows.
  3. Restart the MySQL service to see if the error is removed.

Conclusion

In conclusion, the MySQL service may shut down unexpectedly for various reasons. The most common cause is attempting to reinstall it. Nevertheless, you don't need to worry when this occurs. Most local environments provide solutions to address the issue, with XAMPP offering some of the easiest and most straightforward methods, which we have discussed in this blog.

Frequently Asked Questions

Are There Any Other Web Servers That You Can Use?

Yes, numerous other web servers are available on the internet. XAMPP is managed by Apache Friends. Some of its major competitors include Nginx and Apache itself. Other options you can consider are MAMP, WampServer, or EasyPHP.

Which is the Best Web Server?

The best web server for you depends on your specific needs and budget.

What is the 3306 Port Used for?

The 3306 port is generally used for running the MySQL service on your system. It serves as the default port for the service, but other services and apps may sometimes share the port as well, potentially causing an error.

Flona
Flona / Customer Support Team @GMO

A Boss Level Tech nerd. Her interests range from all things web hosting to swiping food from the pantry. As she says, free food is the best food. You can't out nerd her and your food is definitely not safe when she's around.

PROMO

FREE Web Hosting
for Your Website

Learn More
Rowena

PROMO

FREE Web Hosting
for Your Website

Learn More
Rowena