{"slug": "repair-mysql-data-directory-for-xampp", "title": "Repair MySQL data directory (for XAMPP)", "summary": "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`.", "body_md": "repair-mysql-data.ps1\n\n      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.\n      \nLearn more about bidirectional Unicode characters\n\n \n    Show hidden characters\n\n# Based on this answer: https://stackoverflow.com/a/61859561/1956278\n\n# Backup old data\n\nRename-Item -Path \"./data\" -NewName \"./data_old\"\n\n# Create new data directory\n\nCopy-Item -Path \"./backup\" -Destination \"./data\" -Recurse\n\nRemove-Item \"./data/test\" -Recurse\n\n$dbPaths = Get-ChildItem -Path \"./data_old\" -Exclude ('mysql', 'performance_schema', 'phpmyadmin') -Recurse -Directory\n\nCopy-Item -Path $dbPaths.FullName -Destination \"./data\" -Recurse\n\nCopy-Item -Path \"./data_old/ibdata1\" -Destination \"./data/ibdata1\"\n\n# Notify user\n\nWrite-Host \"Finished repairing MySQL data\"\n\nWrite-Host \"Previous data is located at ./data_old\"", "url": "https://wpnews.pro/news/repair-mysql-data-directory-for-xampp", "canonical_source": "https://gist.github.com/josemmo/24e35f2b4984a4370ce2c164f5956437", "published_at": "2020-08-28 18:48:42+00:00", "updated_at": "2026-05-23 01:05:53.879851+00:00", "lang": "en", "topics": ["developer-tools", "data"], "entities": ["XAMPP", "MySQL"], "alternates": {"html": "https://wpnews.pro/news/repair-mysql-data-directory-for-xampp", "markdown": "https://wpnews.pro/news/repair-mysql-data-directory-for-xampp.md", "text": "https://wpnews.pro/news/repair-mysql-data-directory-for-xampp.txt", "jsonld": "https://wpnews.pro/news/repair-mysql-data-directory-for-xampp.jsonld"}}