IT BS Help

How to Reset the Root Password MYSQL

in Coding

1. Stop MYSQL Service

2. Create txt file (C:\mysql_reset.txt) with

UPDATE mysql.user SET Password=PASSWORD(‘yourpassword’) WHERE User=’root’;
FLUSH PRIVILEGES;

3. Run Command Prompt as Administrator then run
C:\mysql\bin\mysqld –init-file=C:\\mysql_reset.txt

if you get an error then create a bat file in the mysql folder and run as admin with contents below will set root password to blank or download the batch here resetroot

@echo off
echo USE mysql; >resetroot.sql
echo. >>resetroot.sql
echo REPLACE INTO user VALUES (‘localhost’, ‘root’, ”, ‘Y’, ‘Y’, ‘Y’, ‘Y’, ‘Y’, ‘Y’, ‘Y’, ‘Y’, ‘Y’, ‘Y’, ‘Y’, ‘Y’, ‘Y’, ‘Y’, ‘Y’, ‘Y’, ‘Y’, ‘Y’, ‘Y’, ‘Y’, ‘Y’, ‘Y’, ‘Y’, ‘Y’, ‘Y’, ‘Y’, ‘Y’, ‘Y’, ‘Y’, ”, ”, ”, ”, 0, 0, 0, 0, ”, ”); >>resetroot.sql
echo REPLACE INTO user VALUES (‘127.0.0.1’, ‘root’, ”, ‘Y’, ‘Y’, ‘Y’, ‘Y’, ‘Y’, ‘Y’, ‘Y’, ‘Y’, ‘Y’, ‘Y’, ‘Y’, ‘Y’, ‘Y’, ‘Y’, ‘Y’, ‘Y’, ‘Y’, ‘Y’, ‘Y’, ‘Y’, ‘Y’, ‘Y’, ‘Y’, ‘Y’, ‘Y’, ‘Y’, ‘Y’, ‘Y’, ‘Y’, ”, ”, ”, ”, 0, 0, 0, 0, ”, ”); >>resetroot.sql
echo REPLACE INTO user VALUES (‘localhost’, ‘pma’, ”, ‘N’, ‘N’, ‘N’, ‘N’, ‘N’, ‘N’, ‘N’, ‘N’, ‘N’, ‘N’, ‘N’, ‘N’, ‘N’, ‘N’, ‘N’, ‘N’, ‘N’, ‘N’, ‘N’, ‘N’, ‘N’, ‘N’, ‘N’, ‘N’, ‘N’, ‘N’, ‘N’, ‘N’, ‘N’, ”, ”, ”, ”, 0, 0, 0, 0, ”, ”); >>resetroot.sql

bin\mysqld.exe –no-defaults –bind-address=127.0.0.1 –bootstrap –console –standalone nul
del resetroot.sql
echo.
echo Passwoerter fuer Benutzer “root” und “pma” wurden geloescht.
echo Passwords for user “root” and “pma” were deleted.
echo.
pause

0