@echo off
echo ===== MySQL Database Repair Script =====
echo.
echo This script will:
echo 1. Stop MySQL services
echo 2. Add innodb_force_recovery=1 to my.ini
echo 3. Restart MySQL to attempt recovery
echo.
echo Please run this script as Administrator!
echo.
pause

echo Stopping MySQL services...
net stop MySQL
taskkill /F /IM mysqld.exe /T

echo.
echo Backing up my.ini...
copy "C:\xampp\mysql\bin\my.ini" "C:\xampp\mysql\bin\my.ini.bak"

echo.
echo Adding recovery mode to my.ini...
echo. >> "C:\xampp\mysql\bin\my.ini"
echo # Added for database recovery >> "C:\xampp\mysql\bin\my.ini"
echo innodb_force_recovery=1 >> "C:\xampp\mysql\bin\my.ini"

echo.
echo Configuration updated.
echo.
echo You can now start MySQL from XAMPP Control Panel.
echo After successful recovery, you should remove the innodb_force_recovery line from my.ini
echo.
pause
