windwos 环境下脚本重置mysql密码

保存为123.bat就可以了~~~~~~~~~~~~~~~~~~!
  
  
  
  
  1. :reset_mypwd

  2. @ echo off

  3. title mysql密码重设程序

  4. color 0D

  5. MODE con: COLS=71LINES=25

  6. set /p newpwd=-^> 请输入需要设定的root密码:  

  7. if "%newpwd%"=="" goto reset_mypwd

  8. echo.

  9. :mysqlpath

  10. set /p mysqlpath=-^> 请输入mysql安装路径,带盘符路径:  

  11. if "%mysqlpath%"=="" goto mysqlpath

  12. if not exist %mysqlpath%\my.ini echo -^> 错误的mysql路径输入,请重新输入 & goto mysqlpath

  13. echo.

  14. set tmptxt=%SystemRoot%\Temp\mysql-init.txt

  15. echo SET PASSWORD FOR 'root'@'localhost' = PASSWORD('%newpwd%');>%tmptxt%

  16. net stop mysql

  17. start /b %mysqlpath%\bin\mysqld-nt.exe --defaults-file="%mysqlpath%\my.ini"--init-file=%SystemRoot%\Temp\mysql-init.txt

  18. %mysqlpath%\bin\mysqladmin.exe shutdown -uroot -p"%newpwd%"

  19. rem tskill mysqld-nt

  20. del %SystemRoot%\Temp\mysql-init.txt

  21. echo root 密码已成功被重设为:%newpwd% ,请牢记......

  22. echo 请等待3秒,再按任意键继续......

  23. pause >nul

  24. net start mysql

  25. explorer http://127.0.0.1/phpmyadmin

  26. goto end

本文出自 “峰云,就她了。” 博客,谢绝转载!

你可能感兴趣的:(数据库,职场,MySql重置密码,休闲)