[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

Leave a Reply

Your email address will not be published.