How to fix MySQL error in XAMPP

VPTS Team Content has been moderated
Published date:4/10/2025 Update:4/10/2025 Views:111 Reviews: 5.0/51reviews
VPTS on

When using XAMPP to develop websites or applications, users often encounter MySQL failing to start or throwing port errors. The article below by VPTS Company will guide...

When using XAMPP to develop websites or applications, users often encounter MySQL failing to start or throwing port errors. The article below by VPTS Company explains the causes and provides a quick, simple guide to fixing MySQL errors in XAMPP.

1. Causes of MySQL Errors in XAMPP

Common reasons why MySQL fails to run in XAMPP:

  • Port Conflict:MySQL port 3306 may be occupied by other applications like Skype or MySQL Workbench.

  • MySQL configuration file error:Usually caused by users editing the filemy.iniormy.cnf.
  • Data access permissions:MySQL cannot access directorydata.

  • MySQL service hung:Some legacy processes are still running on the system, causing conflicts during fresh starts.   

2. How to Fix MySQL Errors in XAMPP

Method 1

Step 1:Open XAMPP Control Panel (as Administrator)

  • Go toStart Menu→ typeXAMPP Control Panel → Right-click → Run as administrator.
  • Trong XAMPP Control Panel, StopserviceMySQLif running (click Stop).
how to fix msql error in xampp

Step 2: Rename folderdataintodata_old

Trong C:xamppmysql, right-clickinto folderdata → Rename→ typedata_old → Enter.

how to fix msql error in xampp

Step 3:Create folderdatanew (frombackup)

  • Check if there is a directorybackup trong C:xamppmysqlbackupno.
  • If yes:copy the entire contents ofbackup → pasteintoC:xamppmysqldata(meaning copybackup→ rename todataor create folderdatathen paste the content).
  • If not availablebackup: create a new folder data(Right-click → New → Folder → name itdata).
how to fix msql error in xampp

Step 4:Copy theyour databasefromdata_old → data

  • OpenC:xamppmysqldata_old.
  • Only copy folders named as your databases(for examplemyshop, wordpress...), do not copythe following system directories:

- mysql

- performance_schema

- phpmyadmin

  • Paste database folders intoC:xamppmysqldata. If prompted to overwrite/merge, selectmerge(if you use GUI).

Example: I have a test folder; I will copy the test folder and paste it into the data folder created earlier

how to fix msql error in xampp

Step 5:Copy fileibdata1fromdata_old → data

  • Trong data_oldfind filesibdata1and copy
how to fix msql error in xampp
  • Copy and paste into the data directory.Do not deleteibdata1root atdata_old(backup remains intact).
how to fix msql error in xampp

Method 2

  • The image below shows an error appearing when Start was clicked
Illustration How to fix MySQL errors in XAMPP

Step 1: Stop MySQL.

Step 2:Go to folder C:/xampp/mysql and copy the data directory to back up

Step 3: Go to C:/xampp/mysql) and sort files by 'Type.'

Step 4:Select files of type INFO File and delete them.

Step 5:And after fixing, we have run it successfully.

Fix MySQL error in XAMPP

CONCLUSION

Thus, to fix MySQL errors in XAMPP, you should check common causes sequentially, such as port conflicts (port 3306), corrupted ibdata1 files, inactive MySQL services, or misconfigured my.ini files. Identifying the exact root cause helps you choose the most effective remedy—from changing ports and restarting services to restoring data.

Through the detailed instructions above, VPTS Company hopes you can easily restore MySQL operations and use XAMPP more stably. If you need in-depth technical support, do not hesitate to contact VPTS for the fastest consultation.

VPTS – Comprehensive Digital Infrastructure Solutions Provider

VPTS is a digital infrastructure solution provider in Vietnam, serving deployment, operation, and data storage needs for individuals, developers, and enterprises. The service ecosystem includesVietnam VPS, International VPS, VPS Anti DDoS, Hosting cPanel, dedicated server, Rack rental, Proxy IPv4/IPv6, S3 MinIOandCloud Storage.

Besides providing infrastructure resources, VPTS also focuses on assisting customers with deployment, configuration, and practical troubleshooting. Content on the VPTS Blog is drawn from common scenarios in operating VPS, servers, and online systems, helping readers understand root causes and apply clear solutions.

VPTS – Stable infrastructure, flexible solutions, and continuous partnership throughout operations.

VPTS Team Contact Information