从批处理文件启动和停止 xampp(Mysql、Apache、Tomcat)的可靠方法,不会导致 mysql 数据库崩溃

发布于 2025-01-11 06:46:35 字数 14156 浏览 0 评论 0原文

环境:
我正在使用 Xampp(Mysql、Apache、Tomcat)在 Windows 11 中编写 Java 应用程序。

问题:
每次我忘记关闭xampp并重新启动计算机时,Mysql就会崩溃。 为了解决这个问题,我使用下面的脚本:

# Based on this answer: https://stackoverflow.com/a/61859561/1956278
$loc = "D:\xampp\mysql"
$dataOld = "./data_old_$(get-date -f yyyy-MM-dd-hh-mm-ss)"
$dataOld_ibdata1 = $( $dataOld + "/ibdata1" )
$backup = "./backup"
$target = "./data"
$target_ibdata1 = $( $target + "/ibdata1" )
$targetTest = "./data/test"

Write-Output $( "Will go to dir " + $loc )
pause
Set-Location -Path $loc

Write-Output $( "Will rename data to " + $dataOld )
pause
Rename-Item -Path $target -NewName $dataOld

Write-Output $( "Will copy data from " + $backup + " to " +  $target )
pause
Copy-Item -Path $backup -Destination $target -Recurse

Write-Output $( "Will delete directory " + $targetTest )
pause
Remove-Item $targetTest -Recurse

Write-Output $( "Will restore databases except mysql,performance_schema,phpmyadmin from " + $dataOld + " to " + $target )
pause
$dbPaths = Get-ChildItem -Path $dataOld -Exclude ('mysql', 'performance_schema', 'phpmyadmin') -Recurse -Directory
Copy-Item -Path $dbPaths.FullName -Destination $target -Recurse

Write-Output $( "Will restore ibdata1 from " + $dataOld_ibdata1 + " to " + $target_ibdata1 )
pause
Copy-Item -Path $dataOld_ibdata1 -Destination $target_ibdata1 

Write-Output $( "Previous data is located at " + $dataOld )
Write-Output $( "goto http://localhost/phpmyadmin and press log-out once!" )
pause

需要:
我希望不使用 xampp 用户界面,而是使用 bat 文件来控制启动和停止程序。

我到目前为止进展如何:
通过使用答案“https://stackoverflow.com/questions/26941864/how-to-find-out-if-tomcat-has-stopped-running-with-batch”我尝试合并bat文件。
我为 xampp 编写了启动和停止程序。
启动程序工作;但是在停止过程中,即使tomcat的pid文件不存在,我也可以看到tomcat正在从xampp界面运行。

XAMPP 起始代码:
我在命令中使用“start”来查看命令提示符中的输出。
“C:\me\codes\GWT\bat\xampp_start.bat”

@echo off
cls

Rem BASE XAMMP DIR
set xampp=d:\xampp\
echo xampp dir %xampp%

Rem MYSQL.EXE
set mysql=%xampp%mysql\bin\mysql.exe
echo mysql file %mysql%

Rem CHECK IF MYSQL IS ACTIVE ALREADY
echo \q | %mysql% -u root 2>nul
if "%ERRORLEVEL%" == "0" (
    echo mysql already running
    GOTO :mysql_already_running
) else (
    echo need to start mysql
)

Rem START MYSQL
@echo mysql_start...
start /b "MYSQL" %xampp%mysql_start.bat

Rem WAIT UNTIL MYSQL STARTED
:check_mysql_running
@echo wait5...
TIMEOUT 5

echo \q | %mysql% -u root 2>nul
if "%ERRORLEVEL%" == "0" (
    echo CONNECTION SUCCESSFUL
) else (
  echo CONNECTION FAILED
  GOTO :check_mysql_running
)

Rem BY NOW MYSQL SHOULD BE STARTED
:mysql_already_running

@echo apache_start...
start /b "APACHE" %xampp%apache_start.bat

@echo catalina_start...
start /b "TOMCAT" %xampp%catalina_start.bat

XAMPP 停止代码:
我在命令中使用了“call”来顺序运行。
“C:\me\codes\GWT\bat\xampp_stop.bat”

@echo off
cls

Rem BASE XAMMP DIR
set xampp=d:\xampp\
echo xampp dir %xampp%

Rem MYSQL.EXE
set mysql=%xampp%mysql\bin\mysql.exe
echo mysql file %mysql%

Rem PID FILE
set pid=%xampp%tomcat\logs\catalina.pid
echo pid file %pid%

Rem TASKLIST FILE
set tasklist=%xampp%tomcat\logs\tasklist.pid
echo tasklist file %tasklist%

Rem FETCH PID of TOMCAT
echo fetching pid id...
setlocal enabledelayedexpansion
set count=0
for /f "tokens=*" %%x in (%pid%) do (
    set /a count+=1
    set var[!count!]=%%x
)
echo pid content %var[1]%
IF [!var[1]!] == [] GOTO :tomcat_stoped

Rem CHECK TOMCAT RUNNING
:check_tomcat_running
@echo catalina_stop...
call %xampp%catalina_stop.bat

@echo wait5...
TIMEOUT 5

echo fetching tasklist...
tasklist /fi "pid eq %var[1]%" > %tasklist%
set count=0
for /f "tokens=*" %%x in (%tasklist%) do (
    set /a count+=1
    set var[!count!]=%%x
)
echo tasklist content 1 %var[1]%
echo tasklist content 2 %var[2]%
echo tasklist content 3 %var[3]%
echo tasklist content 4 %var[4]%
echo tasklist content 5 %var[5]%

echo isEmpty var[3]
IF [!var[3]!] == [] GOTO :tomcat_stoped
GOTO :check_tomcat_running

Rem TOMCAT ALREADY STOPPED
:tomcat_stoped
@echo catalina_stop has stopped

Rem STOP APACHE
call %xampp%apache_stop.bat
@echo apache_stop has stopped

Rem STOP MYSQL
call %xampp%mysql_stop.bat     
@echo mysql_stop has stopped

Rem CHECK IF MYSQL CLOSED
:check_mysql_closed
echo \q | %mysql% -u root 2>nul
if "%ERRORLEVEL%" == "0" (
    echo mysql still running...
    @echo wait5...
    TIMEOUT 5
    GOTO :check_mysql_closed
) else (
  echo mysql stopped.
)

启动输出:
一切看起来都很好...

xampp dir d:\xampp\
mysql file d:\xampp\mysql\bin\mysql.exe
need to start mysql
mysql_start...
wait5...
Diese Eingabeforderung nicht waehrend des Running beenden
Please dont close Window while MySQL is running
MySQL is trying to start
Please wait  ...
MySQL is starting with mysql\bin\my.ini (console)

Waiting for 0 seconds, press a key to continue ...2022-03-09  8:14:36 0 [Note] Using unique option prefix 'key_buffer' is error-prone
CONNECTION SUCCESSFUL future. Please use the full name 'key_buffer_size' instead.
apache_start...4:36 0 [Note] mysql\bin\mysqld (mysqld 10.4.22-MariaDB) starting as process 11472 ...
catalina_start...

C:\me\codes\GWT\bat>Diese Eingabeforderung nicht waehrend des Running beenden
Bitte erst bei einem gewollten Shutdown schliessen
Please close this command only for Shutdown
Apache 2 is starting ...

[XAMPP]: Searching for JDK or JRE HOME with reg query ...
ERROR: The system was unable to find the specified registry key or value.
. [XAMPP]: Could not find 32 bit or 64 bit JDK
. [XAMPP]: Looking for 32 bit JDK on 64 bit machine

HKEY_LOCAL_MACHINE\SOFTWARE\JavaSoft\JDK
    CurrentVersion    REG_SZ    15

HKEY_LOCAL_MACHINE\SOFTWARE\JavaSoft\JDK\15
    JavaHome    REG_SZ    C:\Program Files\AdoptOpenJDK\jdk-15.0.2.7-hotspot\

HKEY_LOCAL_MACHINE\SOFTWARE\JavaSoft\JDK\15.0.2.7
    JavaHome    REG_SZ    C:\Program Files\AdoptOpenJDK\jdk-15.0.2.7-hotspot\


[XAMPP]: Using JDK

[XAMPP]: Seems fine
[XAMPP]: Set JAVA_HOME : C:\Program Files\AdoptOpenJDK\jdk-15.0.2.7-hotspot\
[XAMPP]: Set CATALINA_HOME : d:\xampp\tomcat

Using CATALINA_BASE:   "d:\xampp\tomcat"
Using CATALINA_HOME:   "d:\xampp\tomcat"
Using CATALINA_TMPDIR: "d:\xampp\tomcat\temp"
Using JRE_HOME:        "C:\Program Files\AdoptOpenJDK\jdk-15.0.2.7-hotspot\"
Using CLASSPATH:       "d:\xampp\tomcat\bin\bootstrap.jar;d:\xampp\tomcat\bin\tomcat-juli.jar"
Using CATALINA_OPTS:   "-Dcom.sun.management.jmxremote -Dcom.sun.management.jmxremote.port=8008 -Dcom.sun.management.jmxremote.authenticate=false -Dcom.sun.management.jmxremote.ssl=false"
NOTE: Picked up JDK_JAVA_OPTIONS:  --add-opens=java.base/java.lang=ALL-UNNAMED --add-opens=java.base/java.io=ALL-UNNAMED --add-opens=java.base/java.util=ALL-UNNAMED --add-opens=java.base/java.util.concurrent=ALL-UNNAMED --add-opens=java.rmi/sun.rmi.transport=ALL-UNNAMED
09-Mar-2022 08:14:46.750 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Server version name:   Apache Tomcat/8.5.73
09-Mar-2022 08:14:46.751 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Server built:          Nov 11 2021 13:14:36 UTC
09-Mar-2022 08:14:46.751 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Server version number: 8.5.73.0
09-Mar-2022 08:14:46.751 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log OS Name:               Windows 10
09-Mar-2022 08:14:46.752 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log OS Version:            10.0
09-Mar-2022 08:14:46.752 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Architecture:          amd64
09-Mar-2022 08:14:46.752 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Java Home:             C:\Program Files\AdoptOpenJDK\jdk-15.0.2.7-hotspot
09-Mar-2022 08:14:46.752 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log JVM Version:           15.0.2+7
09-Mar-2022 08:14:46.752 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log JVM Vendor:            AdoptOpenJDK
09-Mar-2022 08:14:46.752 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log CATALINA_BASE:         D:\xampp\tomcat
09-Mar-2022 08:14:46.752 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log CATALINA_HOME:         D:\xampp\tomcat
09-Mar-2022 08:14:46.753 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: --add-opens=java.base/java.lang=ALL-UNNAMED
09-Mar-2022 08:14:46.753 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: --add-opens=java.base/java.io=ALL-UNNAMED
09-Mar-2022 08:14:46.753 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: --add-opens=java.base/java.util=ALL-UNNAMED
09-Mar-2022 08:14:46.753 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: --add-opens=java.base/java.util.concurrent=ALL-UNNAMED
09-Mar-2022 08:14:46.753 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: --add-opens=java.rmi/sun.rmi.transport=ALL-UNNAMED
09-Mar-2022 08:14:46.753 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Djava.util.logging.config.file=d:\xampp\tomcat\conf\logging.properties
09-Mar-2022 08:14:46.754 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Djava.util.logging.manager=org.apache.juli.ClassLoaderLogManager
09-Mar-2022 08:14:46.754 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Djdk.tls.ephemeralDHKeySize=2048
09-Mar-2022 08:14:46.754 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Djava.protocol.handler.pkgs=org.apache.catalina.webresources
09-Mar-2022 08:14:46.754 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Dcom.sun.management.jmxremote
09-Mar-2022 08:14:46.754 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Dcom.sun.management.jmxremote.port=8008
09-Mar-2022 08:14:46.754 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Dcom.sun.management.jmxremote.authenticate=false
09-Mar-2022 08:14:46.755 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Dcom.sun.management.jmxremote.ssl=false
09-Mar-2022 08:14:46.755 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Dignore.endorsed.dirs=
09-Mar-2022 08:14:46.755 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Dcatalina.base=d:\xampp\tomcat
09-Mar-2022 08:14:46.755 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Dcatalina.home=d:\xampp\tomcat
09-Mar-2022 08:14:46.755 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Djava.io.tmpdir=d:\xampp\tomcat\temp
09-Mar-2022 08:14:46.755 INFO [main] org.apache.catalina.core.AprLifecycleListener.lifecycleEvent The Apache Tomcat Native library which allows using OpenSSL was not found on the java.library.path: [C:\Program Files\AdoptOpenJDK\jdk-15.0.2.7-hotspot\bin;C:\WINDOWS\Sun\Java\bin;C:\WINDOWS\system32;C:\WINDOWS;C:\Program Files\AdoptOpenJDK\jdk-15.0.2.7-hotspot\bin;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0\;C:\Windows\System32\OpenSSH\;C:\Program Files (x86)\NVIDIA Corporation\PhysX\Common;C:\Program Files\NVIDIA Corporation\NVIDIA NvDLISR;C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;C:\WINDOWS\System32\WindowsPowerShell\v1.0\;C:\WINDOWS\System32\OpenSSH\;C:\Program Files (x86)\Windows Kits\8.1\Windows Performance Toolkit\;C:\Program Files\nodejs\;C:\Program Files (x86)\Certbot\bin;C:\Program Files (x86)\Windows Kits\10\Windows Performance Toolkit\;C:\Users\tugal\AppData\Local\Microsoft\WindowsApps;C:\Users\tugal\AppData\Roaming\npm;C:\Program Files\JetBrains\IntelliJ IDEA Community Edition 2021.2.2\bin;;.]
09-Mar-2022 08:14:46.783 INFO [main] org.apache.coyote.AbstractProtocol.init Initializing ProtocolHandler ["https-jsse-nio-8443"]
09-Mar-2022 08:14:46.968 INFO [main] org.apache.tomcat.util.net.NioSelectorPool.getSharedSelector Using a shared selector for servlet write/read
09-Mar-2022 08:14:46.976 INFO [main] org.apache.catalina.startup.Catalina.load Initialization processed in 402 ms
09-Mar-2022 08:14:47.000 INFO [main] org.apache.catalina.core.StandardService.startInternal Starting service [Catalina]
09-Mar-2022 08:14:47.000 INFO [main] org.apache.catalina.core.StandardEngine.startInternal Starting Servlet engine: [Apache Tomcat/8.5.73]
09-Mar-2022 08:14:47.010 INFO [localhost-startStop-1] org.apache.catalina.startup.HostConfig.deployWAR Deploying web application archive [D:\xampp\tomcat\webapps\app-backup.war]
...deploy...

停止输出:
一切看起来都很好...

xampp dir d:\xampp\
mysql file d:\xampp\mysql\bin\mysql.exe
pid file d:\xampp\tomcat\logs\catalina.pid
tasklist file d:\xampp\tomcat\logs\tasklist.pid
fetching pid id...
The system cannot find the file d:\xampp\tomcat\logs\catalina.pid.
pid content
catalina_stop has stopped
apache_stop has stopped
Mysql shutdowm ...
mysql_stop has stopped
mysql still running...
wait5...

Waiting for 0 seconds, press a key to continue ...
mysql stopped.
C:\me\codes\GWT\bat>

停止命令后的输出:
问题:德国错误中的错误消息说,apache,mysql没有在我希望它们关闭的地方启动。

Apache konnte nicht gestartet werden
Apache could not be started
Press any key to continue . . .
MySQL konnte nicht gestartet werden
MySQL could not be started
Press any key to continue . . .
C:\me\codes\GWT\bat>

并且无论我单击输入多少次,启动命令的输出都会递归地卡住:

C:\me\codes\GWT\bat>
d:\xampp>More?
d:\xampp>
C:\me\codes\GWT\bat>
d:\xampp>
C:\me\codes\GWT\bat>
d:\xampp>
...

问题:
你知道有什么可靠的方法可以从批处理文件启动和停止 xampp 而不导致 mysql 数据库崩溃吗?按顺序排列的含义

完整代码位于 github

THE ENVIRONMENT:
I am using Xampp (Mysql, Apache, Tomcat) for writing Java applications in Windows 11.

THE PROBLEM:
Everytime i forget to close xampp, and restart computer, Mysql crashes.
To solve this I am using the script below:

# Based on this answer: https://stackoverflow.com/a/61859561/1956278
$loc = "D:\xampp\mysql"
$dataOld = "./data_old_$(get-date -f yyyy-MM-dd-hh-mm-ss)"
$dataOld_ibdata1 = $( $dataOld + "/ibdata1" )
$backup = "./backup"
$target = "./data"
$target_ibdata1 = $( $target + "/ibdata1" )
$targetTest = "./data/test"

Write-Output $( "Will go to dir " + $loc )
pause
Set-Location -Path $loc

Write-Output $( "Will rename data to " + $dataOld )
pause
Rename-Item -Path $target -NewName $dataOld

Write-Output $( "Will copy data from " + $backup + " to " +  $target )
pause
Copy-Item -Path $backup -Destination $target -Recurse

Write-Output $( "Will delete directory " + $targetTest )
pause
Remove-Item $targetTest -Recurse

Write-Output $( "Will restore databases except mysql,performance_schema,phpmyadmin from " + $dataOld + " to " + $target )
pause
$dbPaths = Get-ChildItem -Path $dataOld -Exclude ('mysql', 'performance_schema', 'phpmyadmin') -Recurse -Directory
Copy-Item -Path $dbPaths.FullName -Destination $target -Recurse

Write-Output $( "Will restore ibdata1 from " + $dataOld_ibdata1 + " to " + $target_ibdata1 )
pause
Copy-Item -Path $dataOld_ibdata1 -Destination $target_ibdata1 

Write-Output $( "Previous data is located at " + $dataOld )
Write-Output $( "goto http://localhost/phpmyadmin and press log-out once!" )
pause

THE NEED:
I wish not to use xampp user interface but bat files to take control of starting and stoping procedures.

HOW FAR I COME SO FAR:
By using answer "https://stackoverflow.com/questions/26941864/how-to-find-out-if-tomcat-has-stopped-running-with-batch" I tried to combine bat files.
And I wrote, start and stop procedure for xampp.
Start procedure works; however on stop procedure, even if the pid file of tomcat does not exists, I can see that tomcat is running from the xampp interface.

XAMPP START CODE:
I used "start" in the command to see the output in the command prompt.
"C:\me\codes\GWT\bat\xampp_start.bat"

@echo off
cls

Rem BASE XAMMP DIR
set xampp=d:\xampp\
echo xampp dir %xampp%

Rem MYSQL.EXE
set mysql=%xampp%mysql\bin\mysql.exe
echo mysql file %mysql%

Rem CHECK IF MYSQL IS ACTIVE ALREADY
echo \q | %mysql% -u root 2>nul
if "%ERRORLEVEL%" == "0" (
    echo mysql already running
    GOTO :mysql_already_running
) else (
    echo need to start mysql
)

Rem START MYSQL
@echo mysql_start...
start /b "MYSQL" %xampp%mysql_start.bat

Rem WAIT UNTIL MYSQL STARTED
:check_mysql_running
@echo wait5...
TIMEOUT 5

echo \q | %mysql% -u root 2>nul
if "%ERRORLEVEL%" == "0" (
    echo CONNECTION SUCCESSFUL
) else (
  echo CONNECTION FAILED
  GOTO :check_mysql_running
)

Rem BY NOW MYSQL SHOULD BE STARTED
:mysql_already_running

@echo apache_start...
start /b "APACHE" %xampp%apache_start.bat

@echo catalina_start...
start /b "TOMCAT" %xampp%catalina_start.bat

XAMPP STOP CODE:
I used "call" in the command to run sequentially.
"C:\me\codes\GWT\bat\xampp_stop.bat"

@echo off
cls

Rem BASE XAMMP DIR
set xampp=d:\xampp\
echo xampp dir %xampp%

Rem MYSQL.EXE
set mysql=%xampp%mysql\bin\mysql.exe
echo mysql file %mysql%

Rem PID FILE
set pid=%xampp%tomcat\logs\catalina.pid
echo pid file %pid%

Rem TASKLIST FILE
set tasklist=%xampp%tomcat\logs\tasklist.pid
echo tasklist file %tasklist%

Rem FETCH PID of TOMCAT
echo fetching pid id...
setlocal enabledelayedexpansion
set count=0
for /f "tokens=*" %%x in (%pid%) do (
    set /a count+=1
    set var[!count!]=%%x
)
echo pid content %var[1]%
IF [!var[1]!] == [] GOTO :tomcat_stoped

Rem CHECK TOMCAT RUNNING
:check_tomcat_running
@echo catalina_stop...
call %xampp%catalina_stop.bat

@echo wait5...
TIMEOUT 5

echo fetching tasklist...
tasklist /fi "pid eq %var[1]%" > %tasklist%
set count=0
for /f "tokens=*" %%x in (%tasklist%) do (
    set /a count+=1
    set var[!count!]=%%x
)
echo tasklist content 1 %var[1]%
echo tasklist content 2 %var[2]%
echo tasklist content 3 %var[3]%
echo tasklist content 4 %var[4]%
echo tasklist content 5 %var[5]%

echo isEmpty var[3]
IF [!var[3]!] == [] GOTO :tomcat_stoped
GOTO :check_tomcat_running

Rem TOMCAT ALREADY STOPPED
:tomcat_stoped
@echo catalina_stop has stopped

Rem STOP APACHE
call %xampp%apache_stop.bat
@echo apache_stop has stopped

Rem STOP MYSQL
call %xampp%mysql_stop.bat     
@echo mysql_stop has stopped

Rem CHECK IF MYSQL CLOSED
:check_mysql_closed
echo \q | %mysql% -u root 2>nul
if "%ERRORLEVEL%" == "0" (
    echo mysql still running...
    @echo wait5...
    TIMEOUT 5
    GOTO :check_mysql_closed
) else (
  echo mysql stopped.
)

OUTPUT OF START:
Everything looks fine...

xampp dir d:\xampp\
mysql file d:\xampp\mysql\bin\mysql.exe
need to start mysql
mysql_start...
wait5...
Diese Eingabeforderung nicht waehrend des Running beenden
Please dont close Window while MySQL is running
MySQL is trying to start
Please wait  ...
MySQL is starting with mysql\bin\my.ini (console)

Waiting for 0 seconds, press a key to continue ...2022-03-09  8:14:36 0 [Note] Using unique option prefix 'key_buffer' is error-prone
CONNECTION SUCCESSFUL future. Please use the full name 'key_buffer_size' instead.
apache_start...4:36 0 [Note] mysql\bin\mysqld (mysqld 10.4.22-MariaDB) starting as process 11472 ...
catalina_start...

C:\me\codes\GWT\bat>Diese Eingabeforderung nicht waehrend des Running beenden
Bitte erst bei einem gewollten Shutdown schliessen
Please close this command only for Shutdown
Apache 2 is starting ...

[XAMPP]: Searching for JDK or JRE HOME with reg query ...
ERROR: The system was unable to find the specified registry key or value.
. [XAMPP]: Could not find 32 bit or 64 bit JDK
. [XAMPP]: Looking for 32 bit JDK on 64 bit machine

HKEY_LOCAL_MACHINE\SOFTWARE\JavaSoft\JDK
    CurrentVersion    REG_SZ    15

HKEY_LOCAL_MACHINE\SOFTWARE\JavaSoft\JDK\15
    JavaHome    REG_SZ    C:\Program Files\AdoptOpenJDK\jdk-15.0.2.7-hotspot\

HKEY_LOCAL_MACHINE\SOFTWARE\JavaSoft\JDK\15.0.2.7
    JavaHome    REG_SZ    C:\Program Files\AdoptOpenJDK\jdk-15.0.2.7-hotspot\


[XAMPP]: Using JDK

[XAMPP]: Seems fine
[XAMPP]: Set JAVA_HOME : C:\Program Files\AdoptOpenJDK\jdk-15.0.2.7-hotspot\
[XAMPP]: Set CATALINA_HOME : d:\xampp\tomcat

Using CATALINA_BASE:   "d:\xampp\tomcat"
Using CATALINA_HOME:   "d:\xampp\tomcat"
Using CATALINA_TMPDIR: "d:\xampp\tomcat\temp"
Using JRE_HOME:        "C:\Program Files\AdoptOpenJDK\jdk-15.0.2.7-hotspot\"
Using CLASSPATH:       "d:\xampp\tomcat\bin\bootstrap.jar;d:\xampp\tomcat\bin\tomcat-juli.jar"
Using CATALINA_OPTS:   "-Dcom.sun.management.jmxremote -Dcom.sun.management.jmxremote.port=8008 -Dcom.sun.management.jmxremote.authenticate=false -Dcom.sun.management.jmxremote.ssl=false"
NOTE: Picked up JDK_JAVA_OPTIONS:  --add-opens=java.base/java.lang=ALL-UNNAMED --add-opens=java.base/java.io=ALL-UNNAMED --add-opens=java.base/java.util=ALL-UNNAMED --add-opens=java.base/java.util.concurrent=ALL-UNNAMED --add-opens=java.rmi/sun.rmi.transport=ALL-UNNAMED
09-Mar-2022 08:14:46.750 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Server version name:   Apache Tomcat/8.5.73
09-Mar-2022 08:14:46.751 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Server built:          Nov 11 2021 13:14:36 UTC
09-Mar-2022 08:14:46.751 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Server version number: 8.5.73.0
09-Mar-2022 08:14:46.751 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log OS Name:               Windows 10
09-Mar-2022 08:14:46.752 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log OS Version:            10.0
09-Mar-2022 08:14:46.752 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Architecture:          amd64
09-Mar-2022 08:14:46.752 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Java Home:             C:\Program Files\AdoptOpenJDK\jdk-15.0.2.7-hotspot
09-Mar-2022 08:14:46.752 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log JVM Version:           15.0.2+7
09-Mar-2022 08:14:46.752 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log JVM Vendor:            AdoptOpenJDK
09-Mar-2022 08:14:46.752 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log CATALINA_BASE:         D:\xampp\tomcat
09-Mar-2022 08:14:46.752 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log CATALINA_HOME:         D:\xampp\tomcat
09-Mar-2022 08:14:46.753 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: --add-opens=java.base/java.lang=ALL-UNNAMED
09-Mar-2022 08:14:46.753 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: --add-opens=java.base/java.io=ALL-UNNAMED
09-Mar-2022 08:14:46.753 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: --add-opens=java.base/java.util=ALL-UNNAMED
09-Mar-2022 08:14:46.753 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: --add-opens=java.base/java.util.concurrent=ALL-UNNAMED
09-Mar-2022 08:14:46.753 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: --add-opens=java.rmi/sun.rmi.transport=ALL-UNNAMED
09-Mar-2022 08:14:46.753 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Djava.util.logging.config.file=d:\xampp\tomcat\conf\logging.properties
09-Mar-2022 08:14:46.754 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Djava.util.logging.manager=org.apache.juli.ClassLoaderLogManager
09-Mar-2022 08:14:46.754 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Djdk.tls.ephemeralDHKeySize=2048
09-Mar-2022 08:14:46.754 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Djava.protocol.handler.pkgs=org.apache.catalina.webresources
09-Mar-2022 08:14:46.754 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Dcom.sun.management.jmxremote
09-Mar-2022 08:14:46.754 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Dcom.sun.management.jmxremote.port=8008
09-Mar-2022 08:14:46.754 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Dcom.sun.management.jmxremote.authenticate=false
09-Mar-2022 08:14:46.755 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Dcom.sun.management.jmxremote.ssl=false
09-Mar-2022 08:14:46.755 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Dignore.endorsed.dirs=
09-Mar-2022 08:14:46.755 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Dcatalina.base=d:\xampp\tomcat
09-Mar-2022 08:14:46.755 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Dcatalina.home=d:\xampp\tomcat
09-Mar-2022 08:14:46.755 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Djava.io.tmpdir=d:\xampp\tomcat\temp
09-Mar-2022 08:14:46.755 INFO [main] org.apache.catalina.core.AprLifecycleListener.lifecycleEvent The Apache Tomcat Native library which allows using OpenSSL was not found on the java.library.path: [C:\Program Files\AdoptOpenJDK\jdk-15.0.2.7-hotspot\bin;C:\WINDOWS\Sun\Java\bin;C:\WINDOWS\system32;C:\WINDOWS;C:\Program Files\AdoptOpenJDK\jdk-15.0.2.7-hotspot\bin;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0\;C:\Windows\System32\OpenSSH\;C:\Program Files (x86)\NVIDIA Corporation\PhysX\Common;C:\Program Files\NVIDIA Corporation\NVIDIA NvDLISR;C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;C:\WINDOWS\System32\WindowsPowerShell\v1.0\;C:\WINDOWS\System32\OpenSSH\;C:\Program Files (x86)\Windows Kits\8.1\Windows Performance Toolkit\;C:\Program Files\nodejs\;C:\Program Files (x86)\Certbot\bin;C:\Program Files (x86)\Windows Kits\10\Windows Performance Toolkit\;C:\Users\tugal\AppData\Local\Microsoft\WindowsApps;C:\Users\tugal\AppData\Roaming\npm;C:\Program Files\JetBrains\IntelliJ IDEA Community Edition 2021.2.2\bin;;.]
09-Mar-2022 08:14:46.783 INFO [main] org.apache.coyote.AbstractProtocol.init Initializing ProtocolHandler ["https-jsse-nio-8443"]
09-Mar-2022 08:14:46.968 INFO [main] org.apache.tomcat.util.net.NioSelectorPool.getSharedSelector Using a shared selector for servlet write/read
09-Mar-2022 08:14:46.976 INFO [main] org.apache.catalina.startup.Catalina.load Initialization processed in 402 ms
09-Mar-2022 08:14:47.000 INFO [main] org.apache.catalina.core.StandardService.startInternal Starting service [Catalina]
09-Mar-2022 08:14:47.000 INFO [main] org.apache.catalina.core.StandardEngine.startInternal Starting Servlet engine: [Apache Tomcat/8.5.73]
09-Mar-2022 08:14:47.010 INFO [localhost-startStop-1] org.apache.catalina.startup.HostConfig.deployWAR Deploying web application archive [D:\xampp\tomcat\webapps\app-backup.war]
...deploy...

OUTPUT OF THE STOP:
Everything looks fine...

xampp dir d:\xampp\
mysql file d:\xampp\mysql\bin\mysql.exe
pid file d:\xampp\tomcat\logs\catalina.pid
tasklist file d:\xampp\tomcat\logs\tasklist.pid
fetching pid id...
The system cannot find the file d:\xampp\tomcat\logs\catalina.pid.
pid content
catalina_stop has stopped
apache_stop has stopped
Mysql shutdowm ...
mysql_stop has stopped
mysql still running...
wait5...

Waiting for 0 seconds, press a key to continue ...
mysql stopped.
C:\me\codes\GWT\bat>

OUTPUT AFTER STOP COMMAND:
PROBLEM: Error messages in german error says, apache, mysql is not started where i wanted them to close.

Apache konnte nicht gestartet werden
Apache could not be started
Press any key to continue . . .
MySQL konnte nicht gestartet werden
MySQL could not be started
Press any key to continue . . .
C:\me\codes\GWT\bat>

And it OUTPUT OF THE START COMMAND stucks recursively, no matter how many times i click enter:

C:\me\codes\GWT\bat>
d:\xampp>More?
d:\xampp>
C:\me\codes\GWT\bat>
d:\xampp>
C:\me\codes\GWT\bat>
d:\xampp>
...

QUESTION:
Do you know any RELIABLE way of starting and stoping xampp from a batch file without crashing mysql databases? Meaning in sequential order

full code at github

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

余生共白头 2025-01-18 06:46:35

我厌倦了批处理文件地狱。\

在 Windows 中使用 mysql 最可靠的方法是使用服务。
因此,当计算机关闭时,Windows 可以正确启动/停止 mysql。\

我只需单击 XAMPP 应用程序上的服务按钮即可使 apache 和 mysql 服务。
为了开发目的,我使用批处理文件从控制台启动/停止 tomcat。

I am fed up with batch file hell.\

The most reliable way in windows to use mysql is using services.
Hence, the windows can start/stop mysql properly when computer closes.\

I am just clicking service button on XAMPP app to make apache and mysql service.
And I am starting/stoping tomcat from console with a batch files for development purposes.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文