You could encounter issues when working in a local development environment that resemble those on a live server. In some circumstances, MySQL might not be running or it might have abruptly shut down, which would prevent your WordPress website from connecting to its database.
The process of debugging your MySQL database may differ slightly depending on the local environment you employ. Since you can access a control panel with XAMPP instead than relying solely on the command line, the process is very simple.
We’ll define XAMPP and define the “MySQL shutdown unexpectedly” error in this tutorial. After that, we’ll walk you through three ways to remedy it. Let’s start now!
What is XAMPP?
The most widely used PHP development environment is XAMPP. MariaDB, PHP, and Perl are all included in the totally free and simple-to-install Apache distribution known as XAMPP. The XAMPP open-source package has been designed to be extremely simple to use and install.
Instead of setting up each component separately, you may use XAMPP to install all the software you require to operate WordPress locally using a single bundle Different development environments bundle different applications.
The parts that come with XAMPP are as follows:
- Apache: You can host websites using Apache, possibly the most well-liked web server software in the world.
- PHP: WordPress is built on PHP, so in order to use the Content Management System (CMS), you must have PHP installed.
- PERL: WordPress doesn’t use the Perl programming language, yet it is included by default in the XAMPP stack.
- MariaDB: You can manage databases with B, an open-source database program.
You may now access the logs for each of XAMPP’s components thanks to this. It contains an overview log that displays all of the background activity in your surroundings.
However, utilizing a local development distribution does not guarantee that mistakes won’t occur on your server. Software components may occasionally malfunction, as seen in the XAMPP message “MySQL shutdown unexpectedly”.
What Does the “MySQL Shutdown Unexpectedly” XAMPP Error Mean?
As implied by the error’s name, the following message will appear if the MySQL software in your environment abruptly stops working or shuts down: “MySQL shutdown unexpectedly” is a XAMPP error.
Because you can manually terminate the MySQL database software at any time, we say “unexpectedly”. Additionally, it takes place if you restart your server. Your website won’t be able to connect to its database when the program is shut down, though. WordPress won’t function, in other words.
How to resolve the “MySQL Shutdown Unexpectedly” XAMPP error – Solutions Below
The XAMPP error “MySQL shutdown unexpectedly” is typically quick and simple to resolve. We’ll go over three fixes with you below, starting with the easiest.
1. Run XAMPP as an Administrator
When XAMPP is not run with administrator rights, it frequently generates errors. This is due to the possibility that its components cannot be configured or function effectively at lesser authorization levels.
We advise that you completely shut down XAMPP and restart the environment as an administrator if you’re unsure whether that applies to your configuration. To do this in Windows, locate the xampp-control file in the folder where XAMPP was installed. Next, choose Run as administrator by performing a right-click on XAMPP Icon:
If you use macOS, you can choose Get Info from the context menu when you right-click on the folder. Select the Sharing & Permissions area, click the padlock symbol, and then enter your administrator password in the pop-up window that appears. Set Everyone as the Read & Write permissions.
MySQL ought to operate properly after XAMPP is up and functioning in its entirety. This implies that your database will be available.
2. Restoration of Database Backup
Restoring your database’s backup is the next step if restarting XAMPP with administrator rights doesn’t fix the issue. Software in your environment receives automatic backups from XAMPP, which you can access in the folder where it was set up.
Your XAMPP MySQL backup files ought to be located under Local Disk > XAMPP > MySQL by default. You’ll find numerous directories in that directory, including two titled data and backup:
All of the files used by your database can be found in the data folder. There is a single current copy of your MySQL in the backup folder.
Remember! Use the XAMPP control panel to shut down MySQL before restoring the backup files.
By selecting the Stop option on the main menu to the right of the MySQL option, you can create a backup:
Once MySQL has been stopped, go back to the MySQL folder in XAMPP and do the following actions to restore the MySQL backup:
- The data folder should be duplicated.
- Give this new folder copy a new name, such as data-old. Your fallback will be this.
- Transfer the backup folder’s contents to the data folder.
I’m done now! But to be cautious, we strongly advise that you hang onto the data-old folder until you’re certain that everything is operating as it should.
3. Modify the MySQL Port
One of the most frequent reasons for the XAMPP issue “MySQL shutdown unexpectedly” is that another program is using the MySQL port. Typically, it is 3306 by default. Just above the Shell tool in the XAMPP control panel, you can choose the Netstat module to be certain:
Utilizing the command line program Netstat, you can view all of the active connections on your network, along with the ports they are utilizing. Once Netstat has been initialized, you will be able to see what port MySQL and the other tools in your stack are utilizing.
Running MySQL with administrator rights or restoring a backup won’t help if a conflict with that port is what led to the shutdown. Changing the port that MySQL uses is the only method to resolve this problem. You can determine what port it is and which others are in use by using Netstat.
To accomplish this, simply discontinue the service by following the steps we outlined in the previous section. Next, select the my.ini option by clicking the Config icon next to MySQL on the XAMPP main menu:
The parameters for MySQL configuration are found in the my.ini file. When you click on it, XAMPP will use your default text editor to open the file. Once inside, look for the line that says Port, which lists the MySQL port number. Here, you might substitute a different port number that you are confident no other software is utilizing. In most circumstances, we recommend utilizing 3307, which should be available. Save your modifications, then exit the my.ini file.
Then, you can restart MySQL using the XAMPP management panel. Your database should now be operating properly. You will be notified through the control panel’s report if XAMPP is unable to connect to your database using the new port that you set for some reason. If so, you might try switching to a different port.
The settings of your server may occasionally malfunction if you use XAMPP to run WordPress locally. Unexpected MySQL shutdown is one of the most frequent problems.
The good news is that there are three ways you can troubleshoot the problem if this does occur:
- Utilize administrator rights to run XAMPP.
- Your database backup, restore it.
- Modify the MySQL port.