There are a lot of ways to reset the root password for MySQL, which is described in this article using batch processing
@echo off title MySQL:: Find the MySQL installation path from the registry write file Mysql.txt reg Query Hklm\system\controlset001\services\mysql | find/i "ImagePath" >c:\mysql.txt if%errorlevel% neq 0 (echo mysql not found pause exit):: With "as separator, intercept the second paragraph save to variable MYSQLP Ath for/f tokens^=2^ delims^=^ "%%i in (C:\mysql.txt) do set mysqlpath=%%i del c:\mysql.txt/f:: path/replace with \ Set mysqlpath= %mysqlpath:/=\%:: Deletes the last character of the path (the character is not visible, possibly a carriage return, and so on) set mysqlpath=%mysqlpath:~0,-1%: Backtomain:: Get the last character of the path to see not equal to \ Set character=%mysqlpath:~-1,1%:: If the last character is not equal to \, then jump to getpath delete Mysqlpath last character if not%character% = = Goto GetPath:: Enter MYSQ L Installation path C:\Program files\mysql\mysql Server 5.0\bin cd/d "%mysqlpath%":: Echo%mysqlpath% if%errorlevel% neq 0 (Echo MyS QL not found pause exit) Www.jb51.net:: Disable MySQL service, skip permission validation modify password taskkill/f/im mysqld-nt.exe net stop MySQL >nul start /b mysqld-nt--skip-grant-tables ping-n 2 127.0.0.1 >nul echo use MySQL >c:\config.tmp echo update user set Passwor D=password ("") where user= "root";>>C:\config.tmp echo flush privileges; >>c:\config.tmp Echo Exit >>c:\config.tmp:: Read content from file MySQL <c:\config.tmp taskkill/f/im mysqld-because it is interactive Nt.exe net stop MySQL >nul net start MySQL del c:\config.tmp/f pause exit:: Delete the last character of the path, skip back to Main program: GetPath set mysqlpath=% mysqlpath:~0,-1% Goto Backtomain If it is to use Wamp one-click installation needs to change some scripts, mainly the registry search path changes, return value changes, service name changed, MySQL installation path into a D:\wamp\bin\mysql\ Mysql5.5.24\bin, mysqld-nt this thing, there is no mysqld-nt.exe in the process @echo off title MySQL reg query hklm\system\controlset001\ Services\wampmysqld | find/i "ImagePath" >c:\mysql.txt if%errorlevel% neq 0 (echo mysql not found pause exit) for/f "Tokens=3 delims=" %%i in (C:\mysql.txt) do set mysqlpath=%%i del c:\mysql.txt/f set mysqlpath=%mysqlpath:/=\% set mysqlpath=%mysqlpath:~0, -1%: Backtomain set character=%mysqlpath:~-1,1% if not%character% = = Goto GetPath cd/d "%mysqlpath%":: Echo%mysqlpa th% if%errorlevel% neq 0 (echo MySQL not found pause exit) taskkill/f/im mysqld.exe net stop wampmysqld>nul start/b mysqld-nt--skip-grant-tables ping-n 2 127.0.0.1 >nul echo use mysql >c:\config.tmp echo update u Ser set Password=password ("") where user= "root"; >>c:\config.tmp echo flush privileges; >>c:\config.tmp Echo exit >>c:\config.tmp mysql <c:\config.tmp taskkill/f/im mysqld.exe net stop wampmy Sqld >nul net start wampmysqld del c:\config.tmp/f pause Exit:getpath set mysqlpath=%mysqlpath:~0,-1% goto BACKTOMA
In