MYSQL registration Start and Stop unmount batch processing script (Supplement), mysql Batch Processing
The batch file that was written earlier when the mysql interface was debugged.
Register and start my_install.bat
@echo offset MYSQL_DIR=%~dp0rem set MYSQL_DIR=%cd%if not "%MYSQL_HOME%"=="" ( if not "%MYSQL_HOME%"=="%MYSQL_DIR%" ( echo MYSQL_HOME=%MYSQL_HOME% != MYSQL_DIR=%MYSQL_DIR% goto my_ends )) else ( set MYSQL_HOME=%MYSQL_DIR% echo MYSQL_HOME must be set as MYSQL_DIR=%MYSQL_DIR%)set PATH=%MYSQL_HOME%bin;%MYSQL_HOME%lib;%PATH%mysqladmin -uroot ping 1>nul 2>nul@if "%ERRORLEVEL%" == "0" ( echo Mysql is running. goto my_ends)echo "MYSQL_HOME = %MYSQL_HOME%"echo Install and start mysql server ...mysqld --install mysql_srvsc config mysql_srv start= DEMANDrem sc query mysql_srvnet start mysql_srvrem sc query mysql_srvmysqladmin -uroot ping 1>nul 2>nul@if "%ERRORLEVEL%" == "0" echo "Mysql started successfully":my_endscmd /K
Disable uninstall my_uninstall.bat
@echo offset MYSQL_DIR=%~dp0rem set MYSQL_DIR=%cd%if not "%MYSQL_HOME%"=="" ( if not "%MYSQL_HOME%"=="%MYSQL_DIR%" ( echo MYSQL_HOME=%MYSQL_HOME% != MYSQL_DIR=%MYSQL_DIR% goto my_ends )) else set MYSQL_HOME=%MYSQL_DIR%set PATH=%MYSQL_HOME%\bin;%MYSQL_HOME%\lib;%PATH%echo "MYSQL_HOME = %MYSQL_HOME%"echo Stop and uninstall mysql server ...mysqladmin -uroot ping 1>nul 2>nul@if "%ERRORLEVEL%" == "0" ( net stop mysql_srv rem sc query mysql_srv)mysqld --remove mysql_srv:my_endspause