程序師世界是廣大編程愛好者互助、分享、學習的平台,程序師世界有你更精彩!
首頁
編程語言
C語言|JAVA編程
Python編程
網頁編程
ASP編程|PHP編程
JSP編程
數據庫知識
MYSQL數據庫|SqlServer數據庫
Oracle數據庫|DB2數據庫
 程式師世界 >> 數據庫知識 >> MYSQL數據庫 >> MySQL綜合教程 >> MYSQL注冊啟動及停用卸載批處理腳本(補)

MYSQL注冊啟動及停用卸載批處理腳本(補)

編輯:MySQL綜合教程

MYSQL注冊啟動及停用卸載批處理腳本(補)


早前調試mysql接口時候編寫的批處理文件。

注冊啟動 my_install.bat

@echo off
set MYSQL_DIR=%~dp0
rem 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_srv
sc config mysql_srv start= DEMAND
rem sc query mysql_srv
net start mysql_srv
rem sc query mysql_srv

mysqladmin -uroot  ping 1>nul 2>nul
@if "%ERRORLEVEL%" == "0" echo "Mysql started successfully"

:my_ends

cmd /K

停用卸載 my_uninstall.bat

@echo off
set MYSQL_DIR=%~dp0
rem 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_ends

pause



  1. 上一頁:
  2. 下一頁:
Copyright © 程式師世界 All Rights Reserved