Bug #7856 When installing service, server ignores options after --install <name>
Submitted: 13 Jan 2005 0:44 Modified: 17 Feb 2005 17:30
Reporter: Gerardo Narvaja Email Updates:
Status: Closed Impact on me:
None 
Category:MySQL Server Severity:S3 (Non-critical)
Version:5.0.1/2 OS:Windows (W2K and XP)
Assigned to: Jim Winstead CPU Architecture:Any

[13 Jan 2005 0:44] Gerardo Narvaja
Description:
When trying to install mysqld as a service with the following syntax:

mysqld --install MyService --default-files=c:\mypath\myconfig.ini --port=3910

All options after "MyService" are ignored. If the command options are inverted using the command:

mysqld --default-files=c:\mypath\myconfig.ini --install MyService --port=3910

The myconfig.ini file is read, but the port option is ignored.

In version 5.0.1, the error message for the 2nd example  is "ERROR: Unknown option --install"

How to repeat:
1. Invoke the command lines as suggested in the message
2. Go to the Services console
3. Look for the MyService service
4. Left click on it and select Properties
5. Verify the property that describes the command line invocation
[13 Jan 2005 15:31] MySQL Verification Team
Gerardo,

You mentioned option --default-files, but correct option is --defaults-file.
Is this a typo in the bug report or not?

With correct option it works fine for me.
Regarding --port option, it's not supported during service installation. So it's silently ignored.
[13 Jan 2005 17:36] Gerardo Narvaja
It was a typo. I tested the options with --console before installing as a service.

Not taking the --port option is a change in behavior from 4.1.x and is not reflected anywhere in the documentation.
[13 Jan 2005 20:44] MySQL Verification Team
Still can't reproduce it.
Only if I write the option --defaults-file with a typo (as you wrote in the bug report), this option is ignored. Otherwise it works fine. Please, check you write this option correctly.

--port option doesn't work for me with 4.1.8 too, but with 4.1.8 I get an error:

E:\MySQL4_1_8\bin>mysqld-nt.exe --install mysql418 --defaults-file=C:/temp/my.cnf --port=3307
050113 22:04:04 [ERROR] mysqld-nt.exe: unknown option '--install'
[20 Jan 2005 20:10] Gerardo Narvaja
Victoria, you are using the *nix syntax to specify the configuration file: '/' instead of the Windows one: "\". Please retry with the correct path and let me know if it worked.

Gerardo
[21 Jan 2005 10:37] MySQL Verification Team
Tested with the '\' in the path name. Still works fine for me.
What windows distribution do you use? (with installer, without one etc.)
[26 Jan 2005 6:08] Gerardo Narvaja
Batch file to install the service, run the tests and remove the service

Attachment: test_case.bat (application/octet-stream, text), 390 bytes.

[26 Jan 2005 6:10] Gerardo Narvaja
I just attached a batch file to reproduce the bug in a simplified form. 

In versions 4.1.x the expected result is that the first mysqladmin invocation should fail and the 2nd succeed. In the 5.0.x releases, the first one succeeds and the 2nd one fails.

Gerardo
[26 Jan 2005 19:35] Jorge del Conde
I verified this bug using 5.0.2 / xp sp2:

C:\my\mysql\bin>mysqld --install jorge --defaults-file=c:\windows\my.ini --port=
4000
Service successfully installed.

C:\my\mysql\bin>net start jorge
The jorge service is starting.
The jorge service was started successfully.

C:\my\mysql\bin>mysql --port=4000
ERROR 2003 (HY000): Can't connect to MySQL server on 'localhost' (10061)

C:\my\mysql\bin>mysql -h127.0.0.1 --port=4000
ERROR 2003 (HY000): Can't connect to MySQL server on '127.0.0.1' (10061)

C:\my\mysql\bin>mysql
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 1 to server version: 5.0.2-alpha-log

...
[26 Jan 2005 23:37] Jim Winstead
there's no change in behavior from 4.1 here -- "mysqld.exe --install foo --defaults-file=f:\my.ini --port=9999" with 4.1.9 results in "[ERROR] mysqld.exe: unknown option '--install'
[27 Jan 2005 0:25] Jim Winstead
to clarify: the only options supported when installing a service are --defaults-file=file and --local-service (with 5.0). that it does not give error messages when other arguments are supplied is a bug -- it simply ignores those arguments.

4.1 would always accept one additional argument as part of the install, without verifying that the option was --default-file=file. that it does not give an error with other arguments is arguably a bug.

i don't see any technical reason why arbitrary command-line arguments could not be allowed when installing as a service (or even arbitrary placement of the '--install name' parameter) but that is clearly not the intention of the existing code.
[28 Jan 2005 19:33] Jim Winstead
The patch restores 4.1's behavior of allowing any one argument to be specified as part of the service installation, and not just --defaults-file=FILE.
[3 Feb 2005 5:21] Jim Winstead
Reviewed by Reggie Burnett.
[8 Feb 2005 0:51] Jim Winstead
Fix pushed to 5.0.
[17 Feb 2005 17:30] Paul DuBois
The patch makes 5.0 "bug-compatible" with 4.1.
However, it has never been documented that any argument
is allowed after the service name other than --defaults-file,
so we're not going to start documenting that now. It's not
the intended behavior. No documentation change has been
made.
[28 Aug 2006 23:48] [ name withheld ]
I ran: mysqld --install MYSQL --defaults-file="c:\mysql\my.ini"

I am not sure if anyone is aware but msyqld registers the --default-file just fine option however in the regestery under the controlset for where it stores the service information it doesn't output the imagepath key correctly 

What it puts "c:\mysql\bin\mysqld" "--defaults-file=c:\mysql\bin\mysqld" MYSQL

what it should put "c:\mysql\bin\mysqld" --defaults-file="c:\mysql\bin\mysqld" MYSQL

Notice that it doesn't place qoutes in the incorrect place.