XAMPP MySQL not starting on Windows

XAMPP MySQL not starting on Windows

XAMPP is a great tool for web developers who need to host websites locally on their own computers. Unfortunately, because it uses ports and services that are commonly used by other applications, conflicts can happen, causing certain applications on XAMPP to be unable to run.

In this article, we will be exploring what you can do if XAMPP’s Apache service does not run on Windows.

In a previous article, we explored how to troubleshoot situations where XAMPP MySQL does not work on macOS. You may also be looking for solutions to troubleshoot XAMPP Apache for Windows instead too.

  1. The problem
  2. Possible causes and fixes
    1. Data issue during installation
    2. MySQL port problem
  3. Conclusion

1. The problem

If your MySQL module’s status changes to back to stopped every time you try to start it, you are strongly encouraged to read on further to solve this problem.

MySQL fails to start on XAMPP
MySQL fails to start on XAMPP.

Below is a transcription of the error log shown on XAMPP when MySQL fails to start:

[mysql] Attempting to start MySQL service...
[mysql] Status change detected: running
[mysql] Status change detected: stopped
[mysql] Error: MySQL shutdown unexpectedly
[mysql] This may be due to a blocked port, missing dependencies,
[mysql] improper priviliges, a crash, or a shutdown by another method.

If you try to access phpMyAdmin via http://localhost/phpmyadmin with Apache started (and without starting the MySQL module), you will also see the following error screen:

phpMyAdmin connection refused
phpMyAdmin cannot be connected to without starting MySQL.

2. Possible causes and fixes

Below are some common reasons why your XAMPP MySQL module is not running, please let us know if you are facing an issue that is not described in this blog.

a. Data issue during installation

XAMPP automatically creates backups and all necessary files for your environment’s system, so there might have been some error during installation that does not allow MySQL to run properly.

Now, to make sure that everything will be installed correctly, let’s make some changes to the MySQL install files. If some of the steps listed below are not clear, there is also a video below which you can follow.

  1. Go to your XAMPP MySQL directory. By default, it is located under Local Disk → XAMPP → MySQL (e.g. if you installed it under the default C-drive, you will find the folder in C:\xampp\mysql). Here you will be seeing different folders — the ones that we need to use are the data and backup folders
  2. Rename the data folder to data_old.
  3. Create a new folder with the name data. This is the new folder that MySQL will use to replace the old one. Now, we need to fill this folder with certain files.
  4. Go to the backup folder and copy all the files inside it. Paste them into the new data folder.
  5. Now, we need to paste databases into our new data folder. In order to do so, inside the data_old folder, copy the mysQL folder, as well as all the folders under the phpmyadmin folder. If you have only one folder, it is totally okay, just make sure you paste it. There is NO need to copy the performance_schema and phpmyadmin folders.
  6. Last but not least, we need to copy the ibdata1 file. Go to your data_old folder, find the ibdata1 file, and past it into the data folder.

Having done these steps, you are most likely to be able to run your MySQL module. Below is a video showing the entire process:

A video for the steps listed above.

b. MySQL port problem

Sometimes, the default port (3306) that XAMPP MySQL tries to use is already being used by another application. Hence, MySQL is unable to connect to the port, and fails to start.

A simple solution for this problem would be changing the port that MySQL is supposed to use. To do so, follow the next steps:

Where to find MySQL's my.cnf
Where to find MySQL’s my.cnf.
  1. In the XAMPP control panel, click on the Config button of the MySQL module.
  2. In the popped window, select my.ini.
  3. Inside the file, go down and find the section that contains the following line: # The MySQL server. Below this line, you should find the port number, which says port=3306 by default.
  4. I recommend changing this port number to 3307 (you can use any unused port between 1 to 65535).
  5. Save the changes to the file, and try to start MySQL server again.

Article continues after the advertisement:

Below is a snapshot of my my.cnf file, with the part that you need to change highlighted:


# Example MySQL config file for small systems.
# This is for a system with little memory (<= 64M) where MySQL is only used
# from time to time and it's important that the mysqld daemon
# doesn't use much resources.
# You can copy this file to
# C:/xampp/mysql/bin/my.cnf to set global options,
# mysql-data-dir/my.cnf to set server-specific options (in this
# installation this directory is C:/xampp/mysql/data) or
# ~/.my.cnf to set user-specific options.
# In this file, you can use all long options that a program supports.
# If you want to know which options a program supports, run the program
# with the "--help" option.

# The following options will be passed to all MySQL clients
# password       = your_password 

# Here follows entries for some specific programs 

# The MySQL server
# enable-named-pipe

# Change here for bind listening
# bind-address="" 
# bind-address = ::1          # for ipv6

# Where do all the plugins live

# Don't listen on a TCP/IP port at all. This can be a security enhancement,
# if all processes that need to connect to mysqld run on the same host.
# All interaction with mysqld must be made via Unix sockets or named pipes.
# Note that using this option without enabling named pipes on Windows
# (via the "enable-named-pipe" option) will render mysqld useless!
# commented in by lampp security

# Replication Master Server (default)
# binary logging is required for replication
# log-bin deactivated by default since XAMPP 1.4.11

# required unique id between 1 and 2^32 - 1
# defaults to 1 if master-host is not set
# but will not function as a master if omitted
server-id	=1

# Replication Slave (comment out master section to use this)
# To configure this host as a replication slave, you can choose between
# two methods :
# 1) Use the CHANGE MASTER TO command (fully described in our manual) -
#    the syntax is:
#    MASTER_USER=<user>, MASTER_PASSWORD=<password> ;
#    where you replace <host>, <user>, <password> by quoted strings and
#    <port> by the master's port number (3306 by default).
#    Example:
#    MASTER_USER='joe', MASTER_PASSWORD='secret';
# OR
# 2) Set the variables below. However, in case you choose this method, then
#    start replication for the first time (even unsuccessfully, for example
#    if you mistyped the password in master-password and the slave fails to
#    connect), the slave will create a master.info file, and any later
#    change in this file to the variables' values below will be ignored and
#    overridden by the content of the master.info file, unless you shutdown
#    the slave server, delete master.info and restart the slaver server.
#    For that reason, you may want to leave the lines below untouched
#    (commented) and instead use CHANGE MASTER TO (see above)
# required unique id between 2 and 2^32 - 1
# (and different from the master)
# defaults to 2 if master-host is set
# but will not function as a slave if omitted
#server-id       = 2
# The replication master for this slave - required
#master-host     =   <hostname>
# The username the slave will use for authentication when connecting
# to the master - required
#master-user     =   <username>
# The password the slave will authenticate with when connecting to
# the master - required
#master-password =   <password>
# The port the master is listening on.
# optional - defaults to 3306
#master-port     =  <port>
# binary logging - not required for slaves, but recommended

# Point the following paths to different dedicated disks
#tmpdir = "C:/xampp/tmp"
#log-update = /path-to-dedicated-directory/hostname

# Uncomment the following if you are using BDB tables
#bdb_cache_size = 4M
#bdb_max_lock = 10000

# Comment the following if you are using InnoDB tables
#innodb_log_arch_dir = "C:/xampp/mysql/data"
## You can set .._buffer_pool_size up to 50 - 80 %
## of RAM but beware of setting memory usage too high
## Set .._log_file_size to 25 % of buffer pool size

## UTF 8 Settings
#init-connect=\'SET NAMES utf8\'


# Remove the next comment character if you are not familiar with SQL




If you don’t want to change your MySQL port number, you can also find out which application is using MySQL’s default port 3306, so that you can close that application. Click on the Netstat button (shown below), and it will show you all listening sockets on your device, as well as the ports that they are using. You want to find all the service(s) that are using port 3306, then open the Task Manager (Ctrl + Alt + Del) and close the service(s). This should allow you to start XAMPP’s MySQL.

The Netstat button on XAMPP Control Panel
The Netstat button on XAMPP Control Panel.

3. Conclusion

As with the other articles on the blog, we’d love if you leave a comment below, especially if you:

  1. Find any errors in this article.
  2. Find a problem causing this issue that is not described in this article.

We will periodically upload this article with new solutions and issues that we find, and we will credit you if you share your issues and / or solutions! Your comments will add to the information that is already here, and help other future readers!

Article continues after the advertisement:

Leave a Reply

Your email address will not be published. Required fields are marked *

For security, use of Google's reCAPTCHA service is required which is subject to the Google Privacy Policy and Terms of Use.

I agree to these terms.