1、启动
@echo off
chcp 65001
set serviceName=MySQLWB
echo 启动mysql
sc query %serviceName% | findstr /i "SERVICE_NAME" > nul
if %errorlevel% equ 0 (
echo MySQL服务已安装
wmic service where "Name='%serviceName%'" get State | findstr /i "Running" > nul
if %errorlevel% equ 0 (
echo %serviceName%服务已启动,无需再次启动
) else (
echo %serviceName%服务未启动
# 启动mysql服务
echo MySQL服务启动
net start MySQLWB
)
) else (
echo MySQL服务未安装
# 安装mysql服务
cd project/mysql/bin
mysqld --install MySQLWB
# 启动mysql服务
echo MySQL服务启动
net start MySQLWB
)
2、重新启动
@echo off
chcp 65001
set serviceName=MySQLWB
echo 重新启动mysql
sc query %serviceName% | findstr /i "SERVICE_NAME" > nul
if %errorlevel% equ 0 (
echo MySQL服务已安装
echo MySQL服务停止在启动
net stop MySQLWB
) else (
echo MySQL服务未安装
echo 安装mysql服务
cd project/mysql/bin
mysqld --install MySQLWB
)
echo MySQL服务启动
net start MySQLWB
3、停止
@echo off
chcp 65001
set serviceName=MySQLWB
echo 重新启动mysql
sc query %serviceName% | findstr /i "SERVICE_NAME" > nul
if %errorlevel% equ 0 (
echo MySQL服务已安装
echo MySQL服务停止在启动
net stop MySQLWB
) else (
echo MySQL服务未安装,无需停止
)