bat脚本配置和启动非安装版mysql和tomcat

1、Mysql用服务启动

@echo off

if exist "%CATALINA_HOME%" (goto update_CATALINA_HOME) else (goto create_CATALINA_HOME)
:create_CATALINA_HOME
wmic ENVIRONMENT create name="CATALINA_HOME",username="<system>",VariableValue="%cd%\tomcat"
:update_CATALINA_HOME
wmic ENVIRONMENT set name="CATALINA_HOME",username="<system>",VariableValue="%cd%\tomcat"

if exist "%JAVA_HOME%" (goto update_JAVA_HOME) else (goto create_JAVA_HOME)
:create_JAVA_HOME
wmic ENVIRONMENT create name="JAVA_HOME",username="<system>",VariableValue="%cd%\jdk"
:update_JAVA_HOME
wmic ENVIRONMENT set name="JAVA_HOME",username="<system>",VariableValue="%cd%\jdk"

if exist "%ANT_HOME%" (goto update_ANT_HOME) else (goto create_ANT_HOME)
:create_ANT_HOME
wmic ENVIRONMENT create name="ANT_HOME",username="<system>",VariableValue="%cd%\ant"
:update_ANT_HOME
wmic ENVIRONMENT set name="ANT_HOME",username="<system>",VariableValue="%cd%\ant"

wmic ENVIRONMENT set name="CLASSPATH",username="<system>",VariableValue=".;%%JAVA_HOME%%\lib"

@echo off
set MYSQL_HOME=%~dp0mysql
echo MYSQL_HOME=%MYSQL_HOME%
del /F my.ini
echo [client] >> my.ini
echo port = 3306 >> my.ini
echo default_character_set=utf-8 >> my.ini
echo [mysqld] >> my.ini
echo %server_default_character_set%=utf8 >> my.ini
echo default_storage_engine=InnoDB >> my.ini
echo basedir=%MYSQL_HOME%>>my.ini
echo datadir=%MYSQL_HOME%data>> my.ini
echo innodb_data_file=ibdata1:50M;ibdata2:10M:autoextend >> my.ini
echo transaction-isolation=READ-COMMITTED >> my.ini
echo port=%server_port% >> my.ini
echo max_allowed_packet = 64M >> my.ini
echo "my.ini in %MYSQL_HOME% created."
set PATH=%MYSQL_HOME%\bin;%PATH%
if exist "%MYSQL_HOME%\bin\mysqld-nt.exe" call %MYSQL_HOME%\bin\mysqld-nt --install-manual "mysql" --defaults-file="%MYSQL_HOME%my.ini"
if not exist "%MYSQL_HOME%\bin\mysqld-nt.exe" call %MYSQL_HOME%\bin\mysqld --install-manual "mysql" --defaults-file="%MYSQL_HOME%\my.ini"

net start mysql


@echo off

if exist "%CATALINA_HOME%" go startup
echo Cannot find "CATALINA_HOME%"

:startup
call "%CATALINA_HOME%\bin\startup.bat" start

2、Mysql不用服务启动

parameter.bat
set CURRENT_DIR=%cd%
set JAVA_HOME=%CURRENT_DIR%\jdk
set CATALINA_HOME=%CURRENT_DIR%\tomcat
set MYSQL_HOME=%CURRENT_DIR%\mysql
set PATH=%PATH%;%JAVA_HOME%\bin;%CATALINA_HOME%\bin;%MYSQL_HOME%\bin

startdatabase.bat
call parameter.bat
cd %MYSQL_HOME%\bin
mysqld

stopdatabase.bat
call parameter.bat
cd %MYSQL_HOME%\bin
mysqladmin -u root -p shutdown

start.bat
call parameter.bat
call "%CATALINA_HOME%\bin\startup.bat"

stop.bat
call "%CATALINA_HOME%\bin\shutdown.bat"


评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值