Bug #1643 mysqld does not properly register itself as a service
Submitted: 24 Oct 2003 5:58 Modified: 11 Dec 2003 16:51
Reporter: Gilles Levreau Email Updates:
Status: Closed Impact on me:
Category:MySQL Server Severity:S2 (Serious)
Version:4.0.15 OS:Windows (windows 2000)
Assigned to: Michael Widenius CPU Architecture:Any

[24 Oct 2003 5:58] Gilles Levreau
The way the server is registered as a service has been changed in 4.0.15 and does it incorrectly.

When the service is started, it expects the last argument to the program to be
the service name. However, when mysqld registers itself to the Service Control Manager, it omits that service name in the command to call to start the service. Only the executable path and the option is in the command.

When mysql service is started, it does not recognize it has to start as a service, hangs, and abort.

How to repeat:
- open console
- cd to mysql bin directory
- mysqld-nt --install mysql --defaults-file="<my-defaults-file>"
- net start mysql

It hangs and after a while prints an error message reading the server could not be started.

Suggested fix:
In version 4.0.15, this bug can be fixed by adding these lines to sql/mysqld.cpp, line 2570 (in default_service_handling(), after extra_opt has been added to the command):

  /* Add service name at end of command */
  *pos++= ' ';
  pos = strxnmov(pos, (uint) (end-pos), "\"", servicename, "\"", NullS);

Workaround, in the meantime:
- open the registry editor (regedit), go to the key
HKEY_LOCAL_MACHINE\SYSTEM\ControlSet001\Services\<your mysql service name>

- edit the subkey 'ImagePath' and add the service name at the end of the command
(with a space before it).

- start the service
[24 Oct 2003 9:02] Dean Ellis
Verified in 4.0.16.  With additional options --install is not appending the service name.
[11 Dec 2003 16:51] Michael Widenius
Thank you for your bug report. This issue has been committed to our
source repository of that product and will be incorporated into the
next release.

If necessary, you can access the source repository and build the latest
available version, including the bugfix, yourself. More information 
about accessing the source trees is available at

Additional info:

The fix will appear in 4.0.17