Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

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?

share|improve this question

closed as off-topic by Tom O'Connor Aug 14 '13 at 21:20

This question appears to be off-topic. The users who voted to close gave this specific reason:

  • "Questions must be relevant to professional system administration. Server Fault is a site dedicated to professionals; novice questions are off-topic. Please see the Help Center for more information on topicality. The best advice we can give you is to hire a professional to help you out." – Tom O'Connor
If this question can be reworded to fit the rules in the help center, please edit the question.

1 Answer 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.

share|improve this answer

Not the answer you're looking for? Browse other questions tagged or ask your own question.