Repair MySQL data directory (for XAMPP) This article provides a PowerShell script to repair the MySQL data directory in XAMPP by backing up the existing data folder, creating a new one from a backup, and then selectively copying user databases and the essential `ibdata1` file from the old directory. The script excludes system databases like `mysql`, `performance_schema`, and `phpmyadmin` during the recovery process. After completion, it notifies the user that the repair is finished and that the previous data is stored in a folder named `data_old`. repair-mysql-data.ps1 This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters Show hidden characters Based on this answer: https://stackoverflow.com/a/61859561/1956278 Backup old data Rename-Item -Path "./data" -NewName "./data old" Create new data directory Copy-Item -Path "./backup" -Destination "./data" -Recurse Remove-Item "./data/test" -Recurse $dbPaths = Get-ChildItem -Path "./data old" -Exclude 'mysql', 'performance schema', 'phpmyadmin' -Recurse -Directory Copy-Item -Path $dbPaths.FullName -Destination "./data" -Recurse Copy-Item -Path "./data old/ibdata1" -Destination "./data/ibdata1" Notify user Write-Host "Finished repairing MySQL data" Write-Host "Previous data is located at ./data old"