How to fix MySQL shutdown unexpectedly

Note: If you don’t do following very carefully there are chances you can lose your databases. So be very careful to follow point 1. 

  1. Rename the folder xampp/mysql/data to xamppmysql/data_bk
  2. Create a new folder xampp/mysql/data
  3. Copy the content that resides in xampp/mysql/backup to the new mysql/data folder
  4. Copy all your database folders that are in xamppmysql/data_bk to xampp/mysql/data
    Important: Do not copy the mysql, performance_schema, and phpmyadmin folders from xampp/mysql/data_bk
  5. Finally copy the ibdata1 file from xampp/mysql/data_bk and replace it inside xampp/mysql/data folder
  6. Start MySQL from XAMPP control panel