@echo off
echo ===== MySQL Permissions Fix Script =====
echo.
echo This script will:
echo 1. Stop MySQL services
echo 2. Fix permissions on MySQL data files
echo 3. Restart MySQL
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 Setting permissions on MySQL data directory...
icacls "C:\xampp\mysql\data" /grant:r "BUILTIN\Users":(OI)(CI)F
icacls "C:\xampp\mysql\data\ibdata1" /grant:r "BUILTIN\Users":F

echo.
echo Setting permissions on MySQL log files...
icacls "C:\xampp\mysql\data\*.err" /grant:r "BUILTIN\Users":F
icacls "C:\xampp\mysql\data\*.log" /grant:r "BUILTIN\Users":F

echo.
echo Permissions have been updated.
echo.
echo You can now start MySQL from XAMPP Control Panel.
echo.
pause
