How to fix MySQL error in XAMPP
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 file
my.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).
Step 2: Rename folderdataintodata_old
Trong C:xamppmysql, right-clickinto folderdata → Rename→ typedata_old → Enter.
Step 3:Create folderdatanew (frombackup)
- Check if there is a directory
backuptrongC:xamppmysqlbackupno.
- If yes:copy the entire contents of
backup→ pasteintoC:xamppmysqldata(meaning copybackup→ rename todataor create folderdatathen paste the content).
- If not available
backup: create a new folderdata(Right-click → New → Folder → name itdata).
Step 4:Copy theyour databasefromdata_old → data
- Open
C:xamppmysqldata_old.
- Only copy folders named as your databases(for example
myshop,wordpress...), do not copythe following system directories:
- mysql
- performance_schema
- phpmyadmin
- Paste database folders into
C: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
Step 5:Copy fileibdata1fromdata_old → data
- Trong
data_oldfind filesibdata1and copy
- Copy and paste into the data directory.Do not delete
ibdata1root atdata_old(backup remains intact).
Method 2
- The image below shows an error appearing when Start was clicked
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.
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
Website: https://vpts.shop
Facebook: https://www.facebook.com/trang.vpsttt/
Zalo OA: https://zalo.me/vpstttgroup
Hotline: 0328 812 674