Register the green version of MySQL as a service under Windows, or install a version of the MySQL Windows service can be used
Mysql.bat
CLS @echo off: Setting window font colors Color 0a: Setting window title title "MySQL Admin program call:checkadmin goto Menu: Menu: The menu cls Echo.
echo.=-=-=-=-Please select the operation you want for MySQL-=-=-=-=-echo.
Echo.1: Start MySQL echo.
Echo.2: Close MySQL echo.
Echo.3: Restart MySQL echo.
Echo.4: Exit Echo. echo.=-=-=-=-Please enter the item number you want to select ↓-=-=-=-set/p id= if "%id%" = "1" Goto startup if "%id%" = "2" goto shutdown if "%id%" = "3" goto
Reboot if "%id%" = "4" Exit Pause: Start: startup Echo.
Call:checkmysql 1 echo. Start mysql ... net start MySQL echo. start MySQL success!
Pause goto Menu: Stop: Shutdown echo.
Call:checkmysql 2 echo. Close mysql ... net stop "MySQL" echo. Close MySQL Success!
Pause goto Menu: reboot: Reboot echo.
Call:checkmysql 2 echo. Close mysql ... net stop "MySQL" echo. Close MySQL Success! Goto Startup Goto Menu: Exit: Goout pause goto Menu: Check if the MySQL process exists: checkmysql set/a count=0 for/f "Tokens=1 delims=" %%i in (' Tasklist/nh ^| find/i ' mysql ') do (set/a count+=1) if%count% neq 0 if "%1" equ "1" (Echo Warning: MySQL started G
Oto goout) If%count% equ 0 if "%1" equ "2" ( echo Warning: MySQL does not start goto goout: Check to be run as Administrator: checkadmin echo Test am I admin?
>%systemroot%\system32\test.sunhao if not exist%systemroot%\system32\test.sunhao (Echo Warning: Please run as Administrator!) Pause exit) del%systemroot%\system32\test.sunhao
Demo diagram:
The above mentioned is the entire content of this article, I hope you can enjoy, can be proficient in the batch processing has helped.