Click here to Skip to main content
15,893,486 members
Please Sign up or sign in to vote.
4.00/5 (1 vote)
See more:
C++
I have the windows service program which runs and sometime throw exception about system null reference. After my investigation, this is due to MySQL connection cannot establish due to MySql instance not up yet when startup computer. How to solve this problems???

thanks in advance
Posted

You can call the service by command-line. Using Process.Start in C# you can execute the same thing.

Start / Stop / Enable / Disable mysql service[^]
 
Share this answer
 
Comments
vrushali katkade 16-Jul-11 4:56am    
process.start("C:\>net start MYSQL") it will be display exception as The system cannot find the file specified
Tarun.K.S 16-Jul-11 9:14am    
Good link! 5+
If you try to configure your service, you will notice a 'dependencies' tab.
You can always set MySQL to be a dependent service. It will start before your local service start.

You can also configure this via the command prompt - sc config <service1> depend= <service2>
 
Share this answer
 
Comments
vrushali katkade 16-Jul-11 1:30am    
i m not getting where i write "sc config <service1> depend= <service2>" on command prompt.
Abhinav S 16-Jul-11 1:48am    
In the command prompt.

Another way is to type in Services.msc in the start -> run section and then edit the dependency by using the view.
vrushali katkade 16-Jul-11 2:27am    
i want to set dependency through coding when installing the windows service
2.3.5.7. Starting MySQL Server as a Microsoft Windows Service

On Windows, the recommended way to run MySQL is to install it as a Windows service, whereby MySQL starts and stops automatically when Windows starts and stops, and can be managed using the service manager framework. A MySQL server installed as a service can also be controlled from the command line using NET commands, or with the graphical Services utility. Generally, to install MySQL as a Windows service you should be logged in using an account that has administrator rights.

The Services utility (the Windows Service Control Manager) can be found in the Windows Control Panel (under Administrative Tools on Windows 2000, XP, Vista, and Server 2003). To avoid conflicts, it is advisable to close the Services utility while performing server installation or removal operations from the command line.

Before installing MySQL as a Windows service, you should first stop the current server if it is running by using the following command:

C:\> "C:\Program Files\MySQL\MySQL Server 5.1\bin\mysqladmin"
-u root shutdown
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900