我下面從Windows機器上重置MySQL服務器的密碼MySQL網站的instructions ..如何讓周圍的「 - 」操作僅適用於變量或屬性
逐字複製命令:
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
給了我這個錯誤(略):
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
我環顧四周,發現this建議:
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.
我嘗試下面這種格式..即
$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
但後來我得到這個錯誤:
'C:\Program' is not recognised as an internal or external command
我也試着做反勾逃逸:
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
但也有錯誤(簡稱):
unexpected token '`-`-defaults-file.. ' in expression or statement
有什麼想法嗎?
沒了..同樣的錯誤仍然 – abbood
當您在運行會發生什麼命令行? – user3
同樣的錯誤:'C:\程序不被識別爲內部或外部命令,可操作程序或批處理文件' – abbood