2

I am using XAMPP to run Apache, PHP and MySQL on a bunch of remote laptops for our clients. It is just the XAMPP directory with all the files (thumbdrive version, no registry values are added or modified). I have an install file that puts an icon on the user's desktop that runs start.bat from the XAMPP directory. Start.bat basically starts Apache, then MySQL, and then opens a browser to localhost. Everything works great, except that when the icon is clicked the second time, a second mysqld.exe service starts. Apache does not start twice if the icon is clicked twice, but MySQL does. I've tried several Google and Stack Overflow suggestions to check if a service is running and, if so, stop the service from starting again; however, none of those worked.

The batch file that starts MySQL basically has this one command:

mysql\bin\mysqld --defaults-file=mysql\bin\my.ini --standalone --console

How can I keep mysqld.exe from starting twice? Also, is it a big deal if it is running twice? Will that cause any problems when running a query from PHP?

Jonathon
  • 57
  • 1
  • 7

1 Answers1

1

I also posted this on StackOverflow (one of our other devs asked the same question). Here is the answer I found through trial and error (and prayer!):

Modify mysql_start.bat to have this content:

@echo off 
apache\bin\pv mysqld.exe %1 >nul 
if ERRORLEVEL 1 goto Process_NotFound 
echo MySQL is running 
goto END 
:Process_NotFound 
echo Process %1 is not running 
mysql\bin\mysqld.exe --defaults-file=mysql\bin\my.ini --standalone --console
goto finish 
:finish

This checks if the service is running and starts it if not.

Jonathon
  • 57
  • 1
  • 7