我的 MySQL 服務(wù)名為 MySQL80,具體的以實(shí)際為準(zhǔn):文章來源地址http://www.zghlxwxcb.cn/news/detail-724169.html
@echo off
setlocal
:check_status
cls
sc query MySQL80 | find "RUNNING" > nul 2>&1
if %errorlevel%==0 (
echo Current status of MySQL service: Running
) else (
echo Current status of MySQL service: Stopped
)
:menu
echo Choose an option:
echo 1. Start MySQL service
echo 2. Stop MySQL service
echo 3. Exit
set /p choice=Enter an option:
if "%choice%"=="1" (
net start MySQL80
echo MySQL service has been started.
pause
goto check_status
)
if "%choice%"=="2" (
net stop MySQL80
echo MySQL service has been stopped.
pause
goto check_status
)
if "%choice%"=="3" (
echo Exiting the script.
exit /b 0
)
echo Invalid option. Please select again.
pause
goto menu
文章來源:http://www.zghlxwxcb.cn/news/detail-724169.html
到了這里,關(guān)于.bat 批處理 - 查看 MySQL 狀態(tài)然后啟動(dòng)或關(guān)閉的文章就介紹完了。如果您還想了解更多內(nèi)容,請(qǐng)?jiān)谟疑辖撬阉鱐OY模板網(wǎng)以前的文章或繼續(xù)瀏覽下面的相關(guān)文章,希望大家以后多多支持TOY模板網(wǎng)!