您好,欢迎访问本站!登录后台
  • 如果您觉得本站非常有看点,那么赶紧使用Ctrl+D 收藏吧
  • 网站所有资源均来自网络,如有侵权请联系站长删除!

批处理一键重置MySQL的root密码

好文分享 中国人民很行 2014-07-05 220350 次浏览 0个评论
@echo off ECHO 正在更改MYSQL密码 echo use mysql >C:\mysqlpass.txt echo update user set password=password("hao123") where user="root";>>C:\mysqlpass.txt echo flush privileges; >>C:\mysqlpass.txt net stop mysql 2>nul reg query "HKLM\SYSTEM\ControlSet001\Services\mysql" /t REG_EXPAND_SZ |find /i "image" >C:\mysql.txt if %errorlevel% neq 0 goto exit FOR /F "tokens=2,3* delims= " %%i in (C:\mysql.txt) do echo %%j %%k >C:\mysqltemp.txt FOR /F "tokens=1 delims=-" %%i in (C:\mysqltemp.txt) do set mysqlpath=%%i del C:\mysql.txt /f del C:\mysqltemp.txt /f set mysqlpath=%mysqlpath:/=\% set mysqlpath=%mysqlpath:"=% SET mysqlpath=%mysqlpath:~0,-6% if %mysqlpath:~-1% neq \ set mysqlpath=%mysqlpath:~0,-1% cd /d "%mysqlpath%" start mysqld-nt.exe --skip-grant-tables mysql <C:\mysqlpass.txt if %errorlevel% neq 0 goto out goto ok :exit echo 没有发现MYSQL pause del C:\mysqlpass.txt /f exit :out echo 密码设置失败 pause del C:\mysqlpass.txt /f exit :ok del C:\mysqlpass.txt /f taskkill /f /im mysqld-nt.exe >nul echo 密码已成功设成hao123,已复制到剪切板 echo hao123|clip pause net start mysql

已有 220350 位网友参与,快来吐槽:

发表评论

验证码