Home > Database > Mysql Tutorial > body text

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

WBOY
Release: 2016-06-07 15:25:16
Original
1494 people have browsed it

将下列代码保存在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
Copy after login


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

 

source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!