Reputation: 23548
I'm following the instructions from the mysql site on resetting the mysql server's password on a windows machine..
copying the command verbatim:
C:\> "C:\Program Files\MySQL\MySQL Server 5.0\bin\mysqld-nt.exe"
--defaults-file="C:\\Program Files\\MySQL\\MySQL Server 5.0\\my.ini"
--init-file=C:\\mysql-init.txt
gives me this error (abbreviated):
Unexpected token 'defaults-file="C:\Program Files\MySql\Mysql Server 5.0\my.ini"'
in expression or statement.
The '--' operator works only on variables or on properties.
+ CategoryInfo :ParserError: (:) [], ParentContainsErrorRecordException
+ FullyQualifiedErrorId :UnexpectedToken
I looked around and found this suggestion:
Try this:
$cmd= {cmd /c 'C:\Program Files\PostgreSQL\8.3\bin\pg_dump.exe "--encoding=UTF8 --verbose --create --username=postgres -- file=C:\db\Wednesday.pg DB"'}
&$cmd
-- is the Powershell decrement operator. To make it "mundate", it needs to be enclosed in single quotes to suppress parsing it as an operator. You could also escape all the hyphens with backticks, but that's going to get really ugly.
I tried following that format.. ie
$cmd = {cmd /c 'C:\Program Files\MySQL\MySQL Server 5.0\bin\mysqld-nt.exe
"--defaults-file="C:\\Program Files\\MySQL\\MySQL Server 5.0\\my.ini
--init-file=C:\\mysql-init.txt"'}
&$cmd
but then i got this error:
'C:\Program' is not recognised as an internal or external command
I also tried doing the back tick escaping:
C:\> "C:\Program Files\MySQL\MySQL Server 5.0\bin\mysqld-nt.exe"
`-`-defaults-file="C:\\Program Files\\MySQL\\MySQL Server 5.0\\my.ini"
`-`-init-file=C:\\mysql-init.txt
but also got an error (abbreviated):
unexpected token '`-`-defaults-file.. ' in expression or statement
any ideas?
Upvotes: 2
Views: 3928
Reputation: 708
The double dash for stopping parameter-processing is a sad choice for Powershell indeed. I tried to get it working through Invoke-Command, but the below example worked best
&"C:\Program Files\MySQL\MySQL Server 5.0\bin\mysqld-nt.exe" '--defaults-file=""C:\Program Files\MySQL\MySQL Server 5.0\my.ini""' '--init-file="C:\mysql-init.txt"'
The executable between double quotes.
And the every parameter between single quotes, with the parameter value between double quotes (or double-double quotes to make the spaces in a path work)
Upvotes: 6
Reputation: 26160
try the powershell V3 escape sequence --%
PS > echoargs --% --defaults-file="C:\\Program Files\\MySQL\\MySQL Server 5.0\\my.ini"
Arg 0 is <--defaults-file=C:\\Program Files\\MySQL\\MySQL Server 5.0\\my.ini>
Command line:
"C:\Windows\EchoArgs.exe" --defaults-file="C:\\Program Files\\MySQL\\MySQL Server 5.0\\my.ini"
Upvotes: 1
Reputation: 4318
I think your command should be:
$cmd = {cmd /c '"C:\Program Files\MySQL\MySQL Server 5.0\bin\mysqld-nt.exe"
--defaults-file="C:\\Program Files\\MySQL\\MySQL Server 5.0\\my.ini"
--init-file="C:\\mysql-init.txt"'}
you are missing the double quotes
Upvotes: 0