bat启动和停止oracle、mysql服务,bat执行mysql脚本

目录

bat启动oracle

bat停止oracle

bat启动pdborcl

bat启动mysql

bat停止mysql

bat执行mysql脚本

bat执行SQL Server脚本


bat启动oracle

@echo off
rem Copyright (c) 2019 Moses and/or its affiliates.
net start OracleServiceORCL
net start OracleVssWriterORCL
net start OracleOraDB12Home1TNSListener
net start OracleJobSchedulerORCL 
pause

bat停止oracle

@echo off
rem Copyright (c) 2019 Moses and/or its affiliates.
net stop  OracleServiceORCL
net stop  OracleVssWriterORCL
net stop  OracleOraDB12Home1TNSListener
net stop  OracleJobSchedulerORCL 
pause

bat启动pdborcl

sqlplus sys/sys as sysdba @pdborcl.sql
pause  

pdborcl.sql

conn sys/sys as sysdba    
alter session set container=pdborcl; 
startup;
exit 

bat启动mysql

@echo off
rem Copyright (c) 2019 Moses and/or its affiliates.
rem Get Administrator Rights
>nul 2>&1 "%SYSTEMROOT%\system32\cacls.exe" "%SYSTEMROOT%\system32\config\system"
if '%errorlevel%' NEQ '0' (
goto UACPrompt
) else ( goto gotAdmin )
:UACPrompt
echo Set UAC = CreateObject^("Shell.Application"^) > "%temp%\getadmin.vbs"
echo UAC.ShellExecute "%~s0", "", "", "runas", 1 >> "%temp%\getadmin.vbs"
"%temp%\getadmin.vbs"
exit /B
:gotAdmin
if exist "%temp%\getadmin.vbs" ( del "%temp%\getadmin.vbs" )
rem start
net start MySQL

bat停止mysql

@echo off
rem Copyright (c) 2019 Moses and/or its affiliates.
rem Get Administrator Rights
>nul 2>&1 "%SYSTEMROOT%\system32\cacls.exe" "%SYSTEMROOT%\system32\config\system"
if '%errorlevel%' NEQ '0' (
goto UACPrompt
) else ( goto gotAdmin )
:UACPrompt
echo Set UAC = CreateObject^("Shell.Application"^) > "%temp%\getadmin.vbs"
echo UAC.ShellExecute "%~s0", "", "", "runas", 1 >> "%temp%\getadmin.vbs"
"%temp%\getadmin.vbs"
exit /B
:gotAdmin
if exist "%temp%\getadmin.vbs" ( del "%temp%\getadmin.vbs" )
rem stop
net stop MySQL

bat执行mysql脚本

@ECHO OFF 
rem Copyright (c) 2019 Moses and/or its affiliates.
SET bin=D:\program\mysql-5.7.16-winx64\bin
SET dbhost=127.0.0.1
SET dbuser=root
SET dbpasswd=123456
SET dbName=test
rem current directory
SET sqlpath=%~dp0
rem sql file
set sqlfile=update.sql
cmd /k "cd %bin% && mysql -h%dbhost% -u%dbuser% -p%dbpasswd% %dbName% < %sqlpath%%sqlfile% --default-character-set=utf8"
ECHO finish!
PAUSE
@ECHO Done! 

bat执行SQL Server脚本

@echo off
choice /t 3 /c yn /d n /m "Please enter Y to start the SQL SERVER service, N to stop the SQL SERVER service, otherwise automatically choose to start after 3 seconds."

if errorlevel 1 goto start
if errorlevel 2 goto stop

:start
net start SSASTELEMETRY
net start SQLTELEMETRY
net start SSISTELEMETRY130
net start SQLWriter
net start SQLPBENGINE

net start MsDtsServer130
net start MSSQLFDLauncher
net start MSSQLLaunchpad
net start MSSQLSERVER
net start MSSQLServerOLAPService
net start ReportServer
goto end

:stop
net stop SSASTELEMETRY
net stop SQLTELEMETRY
net stop SSISTELEMETRY130
net stop SQLWriter
net stop SQLPBENGINE

net stop MsDtsServer130
net stop MSSQLFDLauncher
net stop MSSQLLaunchpad
net stop MSSQLSERVER
net stop MSSQLServerOLAPService
net stop ReportServer
goto end

:end
echo Thank you for using it. It will be turned off automatically in three seconds.
pause

  • 0
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值