You need to enable JavaScript to run this app.
最新活动
大模型
产品
解决方案
定价
生态与合作
支持与服务
开发者
了解我们

如何解决XAMPP中MySQL意外关闭的报错问题?

Fixing "MySQL shutdown unexpectedly" in XAMPP

Hey there, let's figure out how to fix that MySQL shutdown issue in XAMPP. Looking at your error log, InnoDB seems to finish its initialization steps just fine—but MySQL still crashes unexpectedly. Here are some practical fixes you can try one by one:

1. Check for Port Conflicts

MySQL defaults to using port 3306, which might be occupied by another program (like a separate MySQL/MariaDB instance, or even some antivirus tools).

  • Open the XAMPP Control Panel, click the Config button next to MySQL, then select my.ini.
  • Find the line port=3306 and change it to something else like port=3307, save the file, then restart XAMPP.
  • Alternatively, open Command Prompt and run:
    netstat -ano | findstr :3306
    
    Note the PID of the process using the port, then open Task Manager to end that process before restarting MySQL.

2. Fix Corrupted InnoDB Temporary File

The log mentions the ibtmp1 file, which is InnoDB's temporary tablespace file—corruption here can cause crashes.

  • Fully shut down XAMPP (make sure the MySQL service is stopped).
  • Navigate to C:\xampp\mysql\data and delete the ibtmp1 file.
  • Restart XAMPP's MySQL service; it will automatically generate a new, clean ibtmp1 file.

3. Verify Folder Permissions

MySQL needs read/write access to its data folder to function properly.

  • Right-click the C:\xampp\mysql\data folder, go to Properties > Security.
  • Make sure your current user account has Full Control (at minimum, Read and Write permissions).
  • If permissions are missing, add them and restart the MySQL service.

4. Reset InnoDB Buffer Pool Cache

The log shows MySQL loading the ib_buffer_pool file—sometimes this cache file can become corrupted.

  • Stop the XAMPP MySQL service.
  • Go to C:\xampp\mysql\data and delete the ib_buffer_pool file.
  • Restart MySQL; it will rebuild the buffer pool cache automatically.

5. Kill Leftover MySQL Processes

Sometimes MySQL processes don't shut down completely, blocking a fresh start.

  • Open Task Manager (press Ctrl+Shift+Esc).
  • Find all processes named mysqld.exe, right-click each and select End Task.
  • Try starting MySQL in XAMPP again.

6. Reinitialize MySQL Data Directory (Last Resort)

Only try this if all other steps fail—this will erase all your databases, so back up the C:\xampp\mysql\data folder first!

  • Shut down XAMPP and back up everything in C:\xampp\mysql\data.
  • Delete all files and folders in the data directory (you can leave the mysql, performance_schema, and sys folders if you want, but deleting all is okay too).
  • Open Command Prompt, navigate to C:\xampp\mysql\bin, then run:
    mysqld --initialize-insecure
    
  • This will reinitialize the data directory and create a root account without a password.
  • Start MySQL in XAMPP, then restore your backed-up databases.

内容的提问来源于stack exchange,提问作者Get It

火山引擎 最新活动