Skip to content

Instantly share code, notes, and snippets.

@mounirzx
Created March 12, 2024 11:38
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mounirzx/8fcf26f3cac218a69431194cf958234b to your computer and use it in GitHub Desktop.
Save mounirzx/8fcf26f3cac218a69431194cf958234b to your computer and use it in GitHub Desktop.
MySQL Error Fix for XAMPP
#!/bin/bash
# Backup existing data directory
cp -r /c/xampp/mysql/data /c/xampp/mysql/data_old
# Remove unnecessary directories
rm -r /c/xampp/mysql/data/mysql/ \
/c/xampp/mysql/data/performance_schema/ \
/c/xampp/mysql/data/phpmyadmin/ \
/c/xampp/mysql/data/test/
# Copy backup files back to data directory, excluding ibdata1
find /c/xampp/mysql/backup/ -mindepth 1 -maxdepth 1 ! -name "ibdata1" -exec cp -r {} /c/xampp/mysql/data/
@mounirzx
Copy link
Author

xampp_mysql-error

How to fix MySQL error in XAMPP server.

[mysql] Status change detected: stopped
[mysql] Error: MySQL shutdown unexpectedly.
[mysql] This may be due to a blocked port, missing dependencies,
[mysql] improper privileges, a crash, or a shutdown by another method
[mysql] Press the Logs button to view error logs and check
[mysql] the Windows Event Viewer for more clues
[mysql] If you need more help, copy and post this
[mysql] entire log window on the forums .

Description:

This Gist contains a script to fix the MySQL error in XAMPP by performing necessary file operations. It backs up the existing data directory, removes unnecessary directories, and copies backup files back to the data directory, excluding ibdata1.

Usage:

Follow these steps to use the script:

Download the script from this Gist.
Open Git Bash and navigate to the directory where you downloaded the script.
Run the script using the following command:

bash mysql_fix.sh

The script will execute and fix the MySQL error in XAMPP.
Please ensure that you have the appropriate permissions to execute the script. If not, you can grant execute permission using the following command:

chmod +x mysql_fix.sh

** Note: Make sure to replace /c/xampp with the correct path to your XAMPP installation directory if it's different.**

This Gist provides a simple solution for resolving the MySQL error in XAMPP. Feel free to fork and modify it as needed for your environment. Contributions and feedback are welcome!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment