1

My Xampp server is showing "MySQL shutdown unexpectedly". I did follow some solution to this problem but still it doesn't fix. All I have to do is every time I have to use MYSQL I uninstall and reinstall Xampp and thus it works. But need a proper demonstration and solve for the problem I am facing. It's tedious to reinstall every time.

Tried the following the solve from this thread. Stackoverflow_Fabrizio_Valencia_Solve

  • Rename the folder mysql/data to mysql/data_old (you can use any name)

  • Create a new folder mysql/data

  • Copy the content that resides in mysql/backup to the new mysql/data folder

  • Copy all your database folders that are in mysql/data_old to mysql/data (skipping the mysql, performance_schema, and phpmyadmin folders from data_old)

  • Finally copy the ibdata1 file from mysql/data_old and replace it inside mysql/data folder

  • Start MySQL from XAMPP control panel

Will be grateful if anyone helps me get through this.

4 Answers 4

1

Running Xampp as administrator and then re-downloading Apache and MySQL works. Figured out the solution. Nevertheless, Thanks to the great community!

Sign up to request clarification or add additional context in comments.

Comments

0

Here are the steps I’ve already tried (from a commonly suggested solution):

  1. Stopped all XAMPP services and exited the application.

  2. Went to C:\xampp\mysql directory.

  3. Renamed the data folder to data_old.

  4. Created a new data folder and copied the entire content of the backup folder into it (except ibdata1).

  5. Copied all folders/files from data_old into the new data folder, making sure not to replace any existing files (skipped replacements).

1 Comment

Did this work? What’s the source of these recommendations?
0

Sadly there is no way of fixing permanently.

What I've done is I added .bat script inside xampp/mysql folder that I run every time this happens. This copies backup folder naming it data, and saves old data folder with timestamp.

@echo off
setlocal enabledelayedexpansion

:: Get timestamp (YYYYMMDD_HHMMSS format)
for /f "tokens=2 delims==" %%I in ('wmic os get localdatetime /value') do set datetime=%%I
set timestamp=%datetime:~0,4%%datetime:~4,2%%datetime:~6,2%_%datetime:~8,2%%datetime:~10,2%%datetime:~12,2%

:: Rename data folder
set oldDataFolder=data_%timestamp%
ren data %oldDataFolder%
echo Renamed data to %oldDataFolder%

:: Copy backup folder to new data folder
xcopy /E /I /Q backup data
echo Copied backup folder to new data folder

:: Copy all folders except excluded ones
for /D %%F in (%oldDataFolder%\*) do (
    set folderName=%%~nxF
    if /I not "!folderName!"=="mysql" if /I not "!folderName!"=="phpmyadmin" if /I not "!folderName!"=="performance_schema" if /I not "!folderName!"=="test" (
        xcopy /E /I /Q "%%F" "data\!folderName!"
        echo Copied folder: !folderName!
    )
)

:: Copy ibdata1 file
if exist "%oldDataFolder%\ibdata1" (
    copy /Y "%oldDataFolder%\ibdata1" "data\ibdata1"
    echo Copied ibdata1 file
) else (
    echo ibdata1 file not found!
)

echo Process completed.
pause

Comments

-1

Please check your anti-virus may be its interrupting the xampp and also the port that xampp is using may be used by some other programs. Skype interferes with XAMPP and WAMP on port 80 so install any port checking tool and figure out which program is causing the issue.

I Hope that your problem will be solved by addressing this.

4 Comments

Apache and mysql are two different pieces of software!
Do this 1- Run XAMPP Using Administrator Privileges 2- Change your mySql Port
@BabarSajjad I did try this procedure as well. But didn't work out :/ Also, I am not using any anti-virus.
@BabarSajjad running as Administrator works now. And I had to reinstall Apache and mySql. Thanks!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.