# 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" |
Thanks for the script. It's working fine
This is the way to execute the script
PowerShell.exe -ExecutionPolicy UnRestricted -File repair-mysql-data.ps1
BRILLIANT!!! TKS A LOT
Saved my day! Thanks!
Você salvou minha vida cara!(You saved my life man!) 🎉
Excellent. however, since MySQL shuts down often and we need to run this script frequently to fix the issue, is there a line we can add to the beginning of the script, to delete data_old to make way for the new data_old (new backup)? as @grandeljay points out
This is just so lovely
So Amazing!!!!!!
how to use this bloc of code
Awesome
@safirbltr Go to xampp directly, then go to mysql and then open PowerShell there and simply paste this code.
Thanks!!!!
Amazing! Thanks so much.
thanks man you saved my precious time
thank you saved my time
thank you.
Still helpful even now. Thank you so much!
The best solution ever. it solves the problem in seconds
Thanks a lot
This works! But for time being. MySQL started crashing again. Not a permanent solution.
Thank you very much!!
Ty!
how do we exactly run this script?
thank you.
How to run this script
-
Create a file with the extension ".ps1" in your mysql directory in your xampp folder e.g(repair-mysql-data.ps1).
-
Open the file and paste the above commands in it.
-
Then open the mysql folder in your powershell terminal( left click then you see ) this ⬇️
-
After that run "PowerShell.exe -ExecutionPolicy UnRestricted -File repair-mysql-data.ps1" (your can always replace the name with whatever you have named the script)⬇️
Great! worked!, thank you!
Great work. This works perfectly without errors or stress.
Perfect!
I confirm it still works!
This still works, thank you
thank you very much it still works!
Thanks!