[Windows] Reinitialize corrupted MySQL installation

My Windows development machine MySQL occasionally got corrupted.

The data inside is useless to me, so I just seek for fastest method to get MySQL up and running again.

1. Remove everything but the directory itself in:

"C:\ProgramData\MySQL\MySQL Server 5.7\Data"

2. Run this command in Escalated Command Prompt:

"C:\Program Files\MySQL\MySQL Server 5.7\bin\mysqld.exe" --defaults-file="C:\ProgramData\MySQL\MySQL Server 5.7\my.ini" --initialize

3. Open data directory and open *.err, find the root password with line:
C:\ProgramData\MySQL\MySQL Server 5.7\Data

[Note] A temporary password is generated for root@localhost: agUuyKMy7d?0

4. Launch MySQL CLI to change “expired” password:

“C:\Program Files\MySQL\MySQL Server 5.7\bin\mysql.exe” -uroot -p

5. Update password using SQL:

ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY 'toor';

6. Now you should able to use phpMyAdmin

One Reply to “[Windows] Reinitialize corrupted MySQL installation”

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.