我的 MySQL 服务名为 MySQL80,具体的以实际为准:文章来源地址https://www.toymoban.com/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
文章来源:https://www.toymoban.com/news/detail-724169.html
到了这里,关于.bat 批处理 - 查看 MySQL 状态然后启动或关闭的文章就介绍完了。如果您还想了解更多内容,请在右上角搜索TOY模板网以前的文章或继续浏览下面的相关文章,希望大家以后多多支持TOY模板网!