Home  >  Article  >  Database  >  快速启动关闭MySQL服务的批处理代码

快速启动关闭MySQL服务的批处理代码

WBOY
WBOYOriginal
2016-06-07 15:25:161496browse

将下列代码保存在txt文本里,再把扩展名改为.bat 当需要启动mysql服务的时候,双击这个.bat 文件。关闭时再次双击即可。 @echo offfor /f skip=3 tokens=4 %%i in ('sc query mysql') do set zt=%%i goto :next:nextif /i %zt%==RUNNING (echo 已经发现该服务

 

将下列代码保存在txt文本里,再把扩展名改为.bat

 当需要启动mysql服务的时候,双击这个.bat 文件。关闭时再次双击即可。

@echo off
for /f "skip=3 tokens=4" %%i in ('sc query mysql') do set "zt=%%i" &goto :next

:next
if /i "%zt%"=="RUNNING" (
echo 已经发现该服务在运行,正在已经关闭服务
net stop mysql
) else (
echo 该服务现在处理停止状态,正在现在开启服务
net start mysql
)
exit
pause


 里面的mysql字符对应你的MYSQL服务的名字,共有3处。

 

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Previous article:搭建最小MySQL环境Next article:Oracle SERVICE