I’ve just installed XAMPP for Windows — should be the newest version (XAMPP Control Panel v3.2.1).
Apache is running just fine on port 80 and 443, but MySQL is not starting. When I press the start button, I get this message:
Attempting to start MySQL service…
Then a window pops up and asks me if I want to allow this, which I want. But nothing happens after that. I can press as many times as I want, but with the same result.
What can I do with MySQL?
Melebius
6,2114 gold badges39 silver badges52 bronze badges
asked Jan 22, 2014 at 9:52
5
If you have MySQL already installed on your windows then go to services.msc file on your windows and right click the MySQL file and stop the service, now open your XAMPP and start MySQL. Now MySQL will start on the port 3306.
answered Feb 27, 2016 at 8:39
1
I had an issue with this because I had accidentally installed XAMPP to c:\windows\program files (x86)
which caused a Windows permissions issue.
The installation says not to install it there, but I thought it had said to install it there.
I uninstalled and reinstalled to c:\xampp
and it worked.
answered Jan 15, 2017 at 17:51
EoinEoin
1,4132 gold badges18 silver badges32 bronze badges
2
After Stop xampp, go to configure and change the port 3306 to 3308 of mysql and save. Now start the sql……Enjoy
answered Apr 24, 2016 at 10:16
Alok kumarAlok kumar
811 silver badge1 bronze badge
- In the cmd type:
services.msc
Find MySql and change properties to the disabled. - In the control panel of
Xampp
uninstall MySql by the checkbox on the left side, and install again by the click in the same checkbox.
TrebledJ
8,7337 gold badges26 silver badges48 bronze badges
answered Feb 10, 2019 at 13:29
surbaniaksurbaniak
811 silver badge3 bronze badges
2
Windows 10 Users:
I had this issue too. A little bit of investigating helped out though. I had a problem before this one, that 3306 was being used. So what I found out was that port 3306 was being used by another program. Specifically a JDBC program I was trying to learn and I had xammp installed before I tried this JDBC out. So I deleted the whole file and then here I am, where you’re at. The issue was that my ‘ImagePath'(registry variable) was changed upon installing mySql again. To put it simply, xammp doesn’t know where your mysqld.exe is at anymore, or the file is not in the location that you told it to be. Here’s how to fix it:
- Open run (Win + r) and type ‘regedit’. This is where you edit your registry.
- Navigate to: HKEY_LOCAL_MACHINE > SYSTEM > CurrentControlSet > Services > MySql
- Click on mySql and notice the ImagePath variable. Right click ‘ImagePath’ and click modify.
- Enter the location of your xammp mySqld file (navigate through xammp to find it) Although it is likely the same as mine.
Cool Sources:
https://superuser.com/questions/222238/how-to-change-path-to-executable-for-a-windows-service/252850
https://dev.mysql.com/doc/mysql-windows-excerpt/5.7/en/mysql-installation-windows-path.html
desertnaut
57.9k27 gold badges140 silver badges167 bronze badges
answered Oct 4, 2019 at 23:07
ThomasThomas
2,6321 gold badge9 silver badges16 bronze badges
1
One of many reasons is xampp cannot start MySQL service by itself. Everything you need to do is run mySQL service manually.
First, make sure that ‘mysqld.exe‘ is not running, if have, end it. (go to Task Manager > Progresses Tab > right click ‘mysqld.exe’ > end task)
Open your services.msc by Run (press ‘Window + R’) > services.msc or 0n your XAMPP ControlPanel, click ‘Services’ button.
Find ‘MySQL‘ service, right click and run it.
answered Aug 19, 2016 at 8:06
1
Only stop My sql In Xampp For 15 Min After 15 min restart Mysql .If my sql running But Port Not Showing in Xampp then Click Config > my.ini edit this file and change port no 3306 > 3307 and save and Restart xampp ………
answered Aug 31, 2015 at 9:42
0
Only for windows
I have fixed the mysql startup issue by following below steps
Steps:
-
Open CMD and copy paste the command
netstat -ano | findstr 3306
If you get any result for command then the Port 3306 is active -
Now we want to kill the active port(3306), so now open powershell and paste the command
Stop-Process -Id (Get-NetTCPConnection -LocalPort 3306).OwningProcess -Force
Where 3306 is active port. Now port will be inactive
Start Mysql service from Xampp which will work fine now
Note: This works only if the port 3306 is in active state. If you didn’t get any result from step 1 this method is not applicable. There could be some other errors
For other ports change 3306
to "Required port"
Ways to open CMD and Powershell
- For CMD-> search for cmd from start menu
- For Powershell-> search for powershell from start menu
answered Jan 24, 2020 at 11:20
Had this problem today, on a Windows 10 machine. Opened C:\xampp\data\mysql_error.log
and looked for lines containing [ERROR]
.
Last error line was:
... [ERROR] InnoDB: File (unknown): 'close' returned OS error 206. Cannot continue operation
Important note: if your error is different, google it (you’ll likely find a fix).
Searching for the above error, found this thread on Apache Friends Support Forum, which led me to the fix:
- Open
C:\xampp\mysql\bin\my.ini
and add the following line towards the end of[mysqld]
section (above the line containing## UTF 8 Settings
):
innodb_flush_method=normal
- Restart MySQL service. Should run just fine.
answered Dec 24, 2018 at 7:23
taotao
83.6k16 gold badges115 silver badges150 bronze badges
If you have other testing applications like SQL web batch etc, uninstall them because they are running in port 3306.
answered Nov 8, 2017 at 6:56
I have the same problem. Finally found the solution:
The Relocate XAMPP
option in the setup tool didn’t correctly relocate the paths and corrupted them, I’ve manually changed the directories inside my.ini
(base dir
, data dir
, …). After that mysql started successfully.
answered Feb 26, 2019 at 7:47
SAMProSAMPro
1,0681 gold badge15 silver badges40 bronze badges
I solved this problem by removing all the information in the path
C:\xampp\mysql\data
And copy the information inside this path
C:\xampp\mysql\backup
answered Jan 7 at 16:52
Did you use the default installation path?
In my case, when i ran mysql_start.bat I got the following error:
Can`t find messagefile 'D:\xampp\mysql\share\errmsg.sys'
I moved my xampp folder to the root of the drive and it started working.
desertnaut
57.9k27 gold badges140 silver badges167 bronze badges
answered Feb 4, 2016 at 3:04
OltamorOltamor
1211 silver badge4 bronze badges
I can share how I solved the problem in my case.
It seems that somehow I had mySQL Server 5.7 installed. It didn’t show on Add/Remove Programs list in Windows tough so I wasn’t aware of it. I marked that after I looked up the XAMPP log.
Just after XAMPP launched it has shown in the log that there is a conflict in mySQL and indicated the folder where my mySQL Server 5.7 is installed. I removed mySQL 5.7 manually from Program Files (x86) and ProgramData folder, restarted and XAMPP mySQL started normally then.
I’ve tried only stopping the mySQL service but for me it didn’t work. Only manually deleting all mySQL 5.7 folders seemed to have helped.
K.Dᴀᴠɪs
9,95511 gold badges33 silver badges43 bronze badges
answered Dec 12, 2018 at 21:53
radekradek
471 silver badge7 bronze badges
Everytime my MySQL starts, it will stop, then I noticed that some files are getting generated in C:\xampp\mysql\data. I tried deleting some files (like the Error logs, err file, etc.) on that directory. Back up first what you’re going to delete to avoid losing data.
I don’t know how it works. I’m just trying to enable HTTPS in my local machine but then suddenly MySQL can’t be started. But now it’s working.
I’m using Windows 10 and XAMPP 3.2.4.
answered Nov 30, 2019 at 15:41
BawmBawm
791 silver badge3 bronze badges
This worked for me.
- Search for Services in Windows Start
- Find MySQL in it.
- Right Click and Stop MySQL. Would work on XAMPP Now.
Note: If you wanna use the MYSQL prompt again, you will have to start the MYSQL from Service again.
answered Nov 17, 2021 at 7:03
In my case I had xampp installed with PHP 7.4.
But I needed PHP 8.
I downloaded xampp with PHP 8.
Installed it to C:/xampp8/ folder. When I started the new version, it started successfully.
But then I realized that I needed the database data from the old xampp installation. I stopped the new xampp(php 8 version) , and tried to start xampp (php 7.4 version) and saw that Apache started and was working fine, but mysql was not starting.
I tried many settings but couldn’t start mysql from the old xampp.
Solution in my case to copy the data to the new xampp
I went to C:/xampp_old/mysql/data folder. And saw that each of my database has a separate folder inside data folder. I copied all the folders and pasted into
C:/xampp8/mysql/data/
Then I started new xampp and looked in phpmyadmin via browser and I got all my databases back.
answered Mar 10, 2022 at 14:53
In the xampp control panel, to the left of «MySQL» there is a green checkbox, click it to uninstall MySQL service. After that you can start MySQL from the same control panel. You can install those services again, it will still work.
answered Oct 20, 2022 at 7:26
Sunil KumarSunil Kumar
6,1806 gold badges36 silver badges40 bronze badges
In Windows, you should go: Start > Run > services.msc > Apache 2.4 > Properties > Start Mode > Automatic > Apply > Start > OK > [Same as MySQL]
answered Jan 19, 2015 at 7:17
if all solutions up did not work for you, make sure the service is running and not set to Disabled
!
Go to Services
from Control panel and open Services
,
Search for Apache2.4
and mysql
then switch it to enabled
, in the column of status it should be switched to Running
answered May 2, 2020 at 9:43
AhmadAhmad
1,6165 gold badges24 silver badges46 bronze badges
1
I’ve just installed XAMPP for Windows — should be the newest version (XAMPP Control Panel v3.2.1).
Apache is running just fine on port 80 and 443, but MySQL is not starting. When I press the start button, I get this message:
Attempting to start MySQL service…
Then a window pops up and asks me if I want to allow this, which I want. But nothing happens after that. I can press as many times as I want, but with the same result.
What can I do with MySQL?
Melebius
6,2114 gold badges39 silver badges52 bronze badges
asked Jan 22, 2014 at 9:52
5
If you have MySQL already installed on your windows then go to services.msc file on your windows and right click the MySQL file and stop the service, now open your XAMPP and start MySQL. Now MySQL will start on the port 3306.
answered Feb 27, 2016 at 8:39
1
I had an issue with this because I had accidentally installed XAMPP to c:\windows\program files (x86)
which caused a Windows permissions issue.
The installation says not to install it there, but I thought it had said to install it there.
I uninstalled and reinstalled to c:\xampp
and it worked.
answered Jan 15, 2017 at 17:51
EoinEoin
1,4132 gold badges18 silver badges32 bronze badges
2
After Stop xampp, go to configure and change the port 3306 to 3308 of mysql and save. Now start the sql……Enjoy
answered Apr 24, 2016 at 10:16
Alok kumarAlok kumar
811 silver badge1 bronze badge
- In the cmd type:
services.msc
Find MySql and change properties to the disabled. - In the control panel of
Xampp
uninstall MySql by the checkbox on the left side, and install again by the click in the same checkbox.
TrebledJ
8,7337 gold badges26 silver badges48 bronze badges
answered Feb 10, 2019 at 13:29
surbaniaksurbaniak
811 silver badge3 bronze badges
2
Windows 10 Users:
I had this issue too. A little bit of investigating helped out though. I had a problem before this one, that 3306 was being used. So what I found out was that port 3306 was being used by another program. Specifically a JDBC program I was trying to learn and I had xammp installed before I tried this JDBC out. So I deleted the whole file and then here I am, where you’re at. The issue was that my ‘ImagePath'(registry variable) was changed upon installing mySql again. To put it simply, xammp doesn’t know where your mysqld.exe is at anymore, or the file is not in the location that you told it to be. Here’s how to fix it:
- Open run (Win + r) and type ‘regedit’. This is where you edit your registry.
- Navigate to: HKEY_LOCAL_MACHINE > SYSTEM > CurrentControlSet > Services > MySql
- Click on mySql and notice the ImagePath variable. Right click ‘ImagePath’ and click modify.
- Enter the location of your xammp mySqld file (navigate through xammp to find it) Although it is likely the same as mine.
Cool Sources:
https://superuser.com/questions/222238/how-to-change-path-to-executable-for-a-windows-service/252850
https://dev.mysql.com/doc/mysql-windows-excerpt/5.7/en/mysql-installation-windows-path.html
desertnaut
57.9k27 gold badges140 silver badges167 bronze badges
answered Oct 4, 2019 at 23:07
ThomasThomas
2,6321 gold badge9 silver badges16 bronze badges
1
One of many reasons is xampp cannot start MySQL service by itself. Everything you need to do is run mySQL service manually.
First, make sure that ‘mysqld.exe‘ is not running, if have, end it. (go to Task Manager > Progresses Tab > right click ‘mysqld.exe’ > end task)
Open your services.msc by Run (press ‘Window + R’) > services.msc or 0n your XAMPP ControlPanel, click ‘Services’ button.
Find ‘MySQL‘ service, right click and run it.
answered Aug 19, 2016 at 8:06
1
Only stop My sql In Xampp For 15 Min After 15 min restart Mysql .If my sql running But Port Not Showing in Xampp then Click Config > my.ini edit this file and change port no 3306 > 3307 and save and Restart xampp ………
answered Aug 31, 2015 at 9:42
0
Only for windows
I have fixed the mysql startup issue by following below steps
Steps:
-
Open CMD and copy paste the command
netstat -ano | findstr 3306
If you get any result for command then the Port 3306 is active -
Now we want to kill the active port(3306), so now open powershell and paste the command
Stop-Process -Id (Get-NetTCPConnection -LocalPort 3306).OwningProcess -Force
Where 3306 is active port. Now port will be inactive
Start Mysql service from Xampp which will work fine now
Note: This works only if the port 3306 is in active state. If you didn’t get any result from step 1 this method is not applicable. There could be some other errors
For other ports change 3306
to "Required port"
Ways to open CMD and Powershell
- For CMD-> search for cmd from start menu
- For Powershell-> search for powershell from start menu
answered Jan 24, 2020 at 11:20
Had this problem today, on a Windows 10 machine. Opened C:\xampp\data\mysql_error.log
and looked for lines containing [ERROR]
.
Last error line was:
... [ERROR] InnoDB: File (unknown): 'close' returned OS error 206. Cannot continue operation
Important note: if your error is different, google it (you’ll likely find a fix).
Searching for the above error, found this thread on Apache Friends Support Forum, which led me to the fix:
- Open
C:\xampp\mysql\bin\my.ini
and add the following line towards the end of[mysqld]
section (above the line containing## UTF 8 Settings
):
innodb_flush_method=normal
- Restart MySQL service. Should run just fine.
answered Dec 24, 2018 at 7:23
taotao
83.6k16 gold badges115 silver badges150 bronze badges
If you have other testing applications like SQL web batch etc, uninstall them because they are running in port 3306.
answered Nov 8, 2017 at 6:56
I have the same problem. Finally found the solution:
The Relocate XAMPP
option in the setup tool didn’t correctly relocate the paths and corrupted them, I’ve manually changed the directories inside my.ini
(base dir
, data dir
, …). After that mysql started successfully.
answered Feb 26, 2019 at 7:47
SAMProSAMPro
1,0681 gold badge15 silver badges40 bronze badges
I solved this problem by removing all the information in the path
C:\xampp\mysql\data
And copy the information inside this path
C:\xampp\mysql\backup
answered Jan 7 at 16:52
Did you use the default installation path?
In my case, when i ran mysql_start.bat I got the following error:
Can`t find messagefile 'D:\xampp\mysql\share\errmsg.sys'
I moved my xampp folder to the root of the drive and it started working.
desertnaut
57.9k27 gold badges140 silver badges167 bronze badges
answered Feb 4, 2016 at 3:04
OltamorOltamor
1211 silver badge4 bronze badges
I can share how I solved the problem in my case.
It seems that somehow I had mySQL Server 5.7 installed. It didn’t show on Add/Remove Programs list in Windows tough so I wasn’t aware of it. I marked that after I looked up the XAMPP log.
Just after XAMPP launched it has shown in the log that there is a conflict in mySQL and indicated the folder where my mySQL Server 5.7 is installed. I removed mySQL 5.7 manually from Program Files (x86) and ProgramData folder, restarted and XAMPP mySQL started normally then.
I’ve tried only stopping the mySQL service but for me it didn’t work. Only manually deleting all mySQL 5.7 folders seemed to have helped.
K.Dᴀᴠɪs
9,95511 gold badges33 silver badges43 bronze badges
answered Dec 12, 2018 at 21:53
radekradek
471 silver badge7 bronze badges
Everytime my MySQL starts, it will stop, then I noticed that some files are getting generated in C:\xampp\mysql\data. I tried deleting some files (like the Error logs, err file, etc.) on that directory. Back up first what you’re going to delete to avoid losing data.
I don’t know how it works. I’m just trying to enable HTTPS in my local machine but then suddenly MySQL can’t be started. But now it’s working.
I’m using Windows 10 and XAMPP 3.2.4.
answered Nov 30, 2019 at 15:41
BawmBawm
791 silver badge3 bronze badges
This worked for me.
- Search for Services in Windows Start
- Find MySQL in it.
- Right Click and Stop MySQL. Would work on XAMPP Now.
Note: If you wanna use the MYSQL prompt again, you will have to start the MYSQL from Service again.
answered Nov 17, 2021 at 7:03
In my case I had xampp installed with PHP 7.4.
But I needed PHP 8.
I downloaded xampp with PHP 8.
Installed it to C:/xampp8/ folder. When I started the new version, it started successfully.
But then I realized that I needed the database data from the old xampp installation. I stopped the new xampp(php 8 version) , and tried to start xampp (php 7.4 version) and saw that Apache started and was working fine, but mysql was not starting.
I tried many settings but couldn’t start mysql from the old xampp.
Solution in my case to copy the data to the new xampp
I went to C:/xampp_old/mysql/data folder. And saw that each of my database has a separate folder inside data folder. I copied all the folders and pasted into
C:/xampp8/mysql/data/
Then I started new xampp and looked in phpmyadmin via browser and I got all my databases back.
answered Mar 10, 2022 at 14:53
In the xampp control panel, to the left of «MySQL» there is a green checkbox, click it to uninstall MySQL service. After that you can start MySQL from the same control panel. You can install those services again, it will still work.
answered Oct 20, 2022 at 7:26
Sunil KumarSunil Kumar
6,1806 gold badges36 silver badges40 bronze badges
In Windows, you should go: Start > Run > services.msc > Apache 2.4 > Properties > Start Mode > Automatic > Apply > Start > OK > [Same as MySQL]
answered Jan 19, 2015 at 7:17
if all solutions up did not work for you, make sure the service is running and not set to Disabled
!
Go to Services
from Control panel and open Services
,
Search for Apache2.4
and mysql
then switch it to enabled
, in the column of status it should be switched to Running
answered May 2, 2020 at 9:43
AhmadAhmad
1,6165 gold badges24 silver badges46 bronze badges
1
Sometimes MySQL may fail to start in XAMPP, which can be a frustrating experience for users. If you are facing this issue, don’t worry, as there are several steps you can take to fix MySQL not starting in XAMPP on Windows. xampp MySQL not starting windows 11/10; In this tutorial, you will learn how to fix MySQL not starting xampp control panel in windows 11/10.
When you start mysql in xampp you will see some errors. Which is visible in the image given below. But your mysql server will not start in xampp windows.So it means that your mysql server has become corrupt. and it needs to be repaired.
This has happened to us on some commits with Windows XAMPP, which appears to be caused by stopping the MySQL server in the control panel.
This was our error log when we tried to start the MySQL server:
3:43:26 PM [mysql] Attempting to start MySQL app... 3:43:26 PM [mysql] Status change detected: running 3:43:28 PM [mysql] Status change detected: stopped 3:43:28 PM [mysql] Error: MySQL shutdown unexpectedly. 3:43:28 PM [mysql] This may be due to a blocked port, missing dependencies, 3:43:28 PM [mysql] improper privileges, a crash, or a shutdown by another method. 3:43:28 PM [mysql] Press the Logs button to view error logs and check 3:43:28 PM [mysql] the Windows Event Viewer for more clues 3:43:28 PM [mysql] If you need more help, copy and post this 3:43:28 PM [mysql] entire log window on the forums
Follow the below given easy steps to fix/resolve MySQL server not starting in XAMPP windows. And your Mysql server will start in the xampp windows:
- Step 1 – Visit Xampp/mysql Directory
- Step 2 – Make Backup Directory
- Step 3 – Copy MySQL Directory Data
- Step 4 – Paste MySQL Data in Directory
- Step 5 – Copy
ibdata1
Directory Data - Step 6 – Restart MySQL Server In Xampp
Step 1 – Visit Xampp/mysql Directory
Navigate to your XAMPP MySQL directory (C:\xampp\mysql
).
Step 2 – Make Backup Directory
Make a new folder called FIX_BACKUP
.
Step 3 – Copy MySQL Directory Data
Copy C:\xampp\mysql\backup
and C:\xampp\mysql\data
into C:\xampp\mysql\FIX_BACKUP
.
Step 4 – Paste MySQL Data in Directory
Paste the contents of C:\xampp\mysql\backup
into C:\xampp\mysql\data
overwriting all the files.
Step 5 – Copy ibdata1
Directory Data
Finally copy the ibdata1
file from C:\xampp\mysql\FIX_BACKUP\data
into C:\xampp\mysql\data
overwriting the file.
Step 6 – Restart MySQL Server In Xampp
Now restart MySQL server in xampp. So, Your MySQL server should now start in the XAMPP control panel.
If the above steps do not resolve the issue, it may be necessary to reinstall XAMPP. This will ensure that all components are installed correctly and that there are no missing or corrupt files. Follow these steps to reinstall XAMPP:
- Uninstall XAMPP from your system.
- Download the latest version of XAMPP from the official website.
- Install XAMPP on your system, making sure to select all the required components.
- Start XAMPP and check if MySQL is running.
Conclusion
MySQL not starting in XAMPP can be a frustrating problem, but fortunately, it can be fixed by following the steps above. By checking the XAMPP control panel, looking for conflicting ports, checking the MySQL error log, and reinstalling XAMPP, you can get MySQL up and running in XAMPP in no time.
Recommended Tutorials
Почему то перестал работать mySQL, сегодня же запускал все было хорошо, может быть кто-нибудь сталкивался? что можно сделать?
18:11:56 [mysql] Error: MySQL shutdown unexpectedly.
18:11:56 [mysql] This may be due to a blocked port, missing dependencies,
18:11:56 [mysql] improper privileges, a crash, or a shutdown by another method.
18:11:56 [mysql] Press the Logs button to view error logs and check
18:11:56 [mysql] the Windows Event Viewer for more clues
18:11:56 [mysql] If you need more help, copy and post this
18:11:56 [mysql] entire log window on the forums
InnoDB: using atomic writes.
2020-04-03 17:41:35 0 [Note] InnoDB: Mutexes and rw_locks use Windows interlocked functions
2020-04-03 17:41:35 0 [Note] InnoDB: Uses event mutexes
2020-04-03 17:41:35 0 [Note] InnoDB: Compressed tables use zlib 1.2.11
2020-04-03 17:41:35 0 [Note] InnoDB: Number of pools: 1
2020-04-03 17:41:35 0 [Note] InnoDB: Using SSE2 crc32 instructions
2020-04-03 17:41:35 0 [Note] InnoDB: Initializing buffer pool, total size = 16M, instances = 1, chunk size = 16M
2020-04-03 17:41:35 0 [Note] InnoDB: Completed initialization of buffer pool
2020-04-03 17:41:35 0 [Note] InnoDB: 128 out of 128 rollback segments are active.
2020-04-03 17:41:35 0 [Note] InnoDB: Creating shared tablespace for temporary tables
2020-04-03 17:41:35 0 [Note] InnoDB: Setting file 'C:\xampp\mysql\data\ibtmp1' size to 12 MB. Physically writing the file full; Please wait ...
2020-04-03 17:41:35 0 [Note] InnoDB: File 'C:\xampp\mysql\data\ibtmp1' size is now 12 MB.
2020-04-03 17:41:35 0 [Note] InnoDB: 10.4.11 started; log sequence number 10282705; transaction id 18356
2020-04-03 17:41:35 0 [Note] InnoDB: Loading buffer pool(s) from C:\xampp\mysql\data\ib_buffer_pool
2020-04-03 17:41:35 0 [Note] Plugin 'FEEDBACK' is disabled.
2020-04-03 17:41:35 0 [Note] Server socket created on IP: '::'.
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.
Note that if you are using XAMPP on macOS, please refer to the following article instead.
If you prefer to watch a video as opposed to reading, we have a video on this as well:
- The problem
- Possible causes and fixes
- Port 3306 is already used by another process
- Changing the port used by XAMPP
- MySQL’s data has been corrupted
- Unable to access phpMyAdmin
- 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.
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.
2. Possible causes and fixes
Below are some common causes that prevent XAMPP’s MySQL module from starting.
a. Port 3306 is used by another process
The most likely reason that XAMPP’s MySQL service is unable to start is because port 3306 is already used by a different program that is currently running on your computer. By default, XAMPP’s MySQL service binds to port 3306 when started, and it can only do so if another program is not already using it.
To ascertain whether this is the case, you can click on the Netstat button to open up a window with a list of all the ports that are being used on your computer currently. If port 3306 is in the list when you haven’t started MySQL on XAMPP, this means that another program is using it.
To remedy this, you will need to find the process that is using port 3306 and end the process. In the example above, a process called mysqld.exe is using port 3306. To stop it, I will have to use Ctrl + Alt + Delete to open up the Task Manager, then find and end the mysqld.exe process.
Once this is done, you can try starting MySQL on XAMPP again. Depending on the program that was occupying port 3306, this might or might not work. If it doesn’t work, you will have to find the program that was creating the process and uninstall it. In most cases, this should be another installation of MySQL on your computer, such as:
- MySQL Workbench
- MySQL Community Server
…or some other variation of MySQL, since it is one of the few programs that use port 3306.
After uninstalling the other program(s), remember to restart your computer before trying to start MySQL again.
b. Changing the port used by XAMPP MySQL
If you don’t want to uninstall the program that is using port 3306, or if you can’t find the process using the instructions above, you can also configure XAMPP MySQL to use a different port. Do note that if another MySQL program is using port 3306, there is a chance that this doesn’t work, as 2 seperate installations of MySQL can interfere with each other.
Regardless, below are the steps to change the port of XAMPP’s MySQL:
- In the XAMPP control panel, click on the Config button of the MySQL module.
- In the popped window, select my.ini.
my.cnf
.- 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 saysport=3306
by default. - Change to a different port. You can use any unused port on your computer between 1 to 65535, but I usually use port 3307.
- Save the changes to the file, and try to start MySQL on XAMPP again.
Article continues after the advertisement:
Below is a snapshot of my my.cnf
file, with the part that you need to change highlighted:
my.cnf
# 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 [client] # password = your_password port=3306 socket="C:/xampp/mysql/mysql.sock" # Here follows entries for some specific programs # The MySQL server default-character-set=utf8mb4 [mysqld] port=33063307 socket="C:/xampp/mysql/mysql.sock" basedir="C:/xampp/mysql" tmpdir="C:/xampp/tmp" datadir="C:/xampp/mysql/data" pid_file="mysql.pid" # enable-named-pipe key_buffer=16M max_allowed_packet=1M sort_buffer_size=512K net_buffer_length=8K read_buffer_size=256K read_rnd_buffer_size=512K myisam_sort_buffer_size=8M log_error="mysql_error.log" # Change here for bind listening # bind-address="127.0.0.1" # bind-address = ::1 # for ipv6 # Where do all the plugins live plugin_dir="C:/xampp/mysql/lib/plugin/" # 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 #skip-networking #skip-federated # Replication Master Server (default) # binary logging is required for replication # log-bin deactivated by default since XAMPP 1.4.11 #log-bin=mysql-bin # 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: # # CHANGE MASTER TO MASTER_HOST=<host>, MASTER_PORT=<port>, # 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: # # CHANGE MASTER TO MASTER_HOST='125.564.12.1', MASTER_PORT=3306, # 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 #log-bin=mysql-bin # 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 #skip-innodb innodb_data_home_dir="C:/xampp/mysql/data" innodb_data_file_path=ibdata1:10M:autoextend innodb_log_group_home_dir="C:/xampp/mysql/data" #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 innodb_buffer_pool_size=16M ## Set .._log_file_size to 25 % of buffer pool size innodb_log_file_size=5M innodb_log_buffer_size=8M innodb_flush_log_at_trx_commit=1 innodb_lock_wait_timeout=50 ## UTF 8 Settings #init-connect=\'SET NAMES utf8\' #collation_server=utf8_unicode_ci #character_set_server=utf8 #skip-character-set-client-handshake #character_sets-dir="C:/xampp/mysql/share/charsets" sql_mode=NO_ZERO_IN_DATE,NO_ZERO_DATE,NO_ENGINE_SUBSTITUTION log_bin_trust_function_creators=1 character-set-server=utf8mb4 collation-server=utf8mb4_general_ci [mysqldump] max_allowed_packet=16M [mysql] # Remove the next comment character if you are not familiar with SQL #safe-updates [isamchk] key_buffer=20M sort_buffer_size=20M read_buffer=2M write_buffer=2M [myisamchk] key_buffer=20M sort_buffer_size=20M read_buffer=2M write_buffer=2M [mysqlhotcopy]
c. MySQL’s data has been corrupted
If you have had multiple copies of MySQL installed on your device at one point, or had a separate installation of XAMPP, it is possible that the data in your current installation might have been corrupted. In such a scenario, you can try:
- Ensuring that all other installations of MySQL are removed on your computer, then uninstalling and reinstalling XAMPP, or;
- Restoring your existing XAMPP’s MySQL installation with backup data.
If you would like to try option B before reinstalling XAMPP, you can follow the steps below:
- 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 thedata
andbackup
folders - Rename the
data
folder todata_old
. - 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. - Go to the
backup
folder and copy all the files inside it. Paste them into the newdata
folder. - Now, we need to paste databases into our new
data
folder. In order to do so, inside thedata_old
folder, copy themysQL
folder, as well as all the folders under thephpmyadmin
folder. If you have only one folder, it is totally okay, just make sure you paste it. There is NO need to copy theperformance_schema
andphpmyadmin
folders. - Last but not least, we need to copy the
ibdata1
file. Go to yourdata_old
folder, find theibdata1
file, and past it into thedata
folder.
3. Unable to access phpMyAdmin
There can also be cases where you are able to start MySQL on XAMPP, but are unable to access the http://localhost/phpmyadmin
URL. This can be caused by a multitude of reasons, and we explore this in a separate article:
4. Conclusion
As with the other articles on the blog, we’d love if you leave a comment below, especially if you:
- Find any errors in this article.
- 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: