Recently with MySQL more time, each time under the Computer Management tools to start, feel very troublesome, so the search has been made by the predecessors have done these things, today collection finishing, MySQL start off batch processing feel very good to find in other forum posts, thanks to the selfless friends on the Internet to share, The following code directly copied and pasted into a bat file double-click to use
Cls
@echo off
: Set Window Font Color
Color 0a
: Set Window Caption
TITLE MySQL Management program
Call:checkadmin
Goto Menu
: Menu
: Menu
Cls
Echo.
echo.=-=-=-=-Please select what you want to do with MySQL-=-=-=-=-
Echo.
Echo.1: Start MySQL
Echo.
Echo.2: Turn off 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. Turn off MySQL ...
net stop "MySQL"
echo. Turn off MySQL success!
Pause
Goto Menu
: Restart
: Reboot
Echo.
Call:checkmysql 2
echo. Turn off MySQL ...
net stop "MySQL"
echo. Turn off 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 is started
Goto Goout
)
If%count% equ 0 if "%1" equ "2" (
echo Warning: MySQL does not start
Goto Goout
)
: Check if you are running as an 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
MySQL start off batch processing, feel very good to find on other forum posts, thanks for sharing