0

Who knows what could be the problem with starting the MongoDB database?

PS C:\Users\Yepo> "C:\Program Files\MongoDB\Server\7.0\bin\mongod.exe" --dbpath="c:\data\db"
At line:1 char:56
+ ... rogram Files\MongoDB\Server\7.0\bin\mongod.exe" --dbpath="c:\data\db" 
Unexpected token 'dbpath="c:\data\db"' in expression or statement.
At line:1 char:1
 "C:\Program Files\MongoDB\Server\7.0\bin\mongod.exe" --dbpath="c:\dat ...

The '--' operator works only on variables or on properties.
    + CategoryInfo          : ParserError: (:) [], ParentContainsErrorRecordException
    + FullyQualifiedErrorId : UnexpectedToken

enter image description here

3
  • Perhaps don't use the =? Should just be "...\mongod.exe" --dbpath "<PATH>" Nov 5, 2023 at 2:11
  • Please clarify your specific problem or provide additional details to highlight exactly what you need. As it's currently written, it's hard to tell exactly what you're asking.
    – Community
    Nov 6, 2023 at 9:47
  • Powershell treats -- as an operator. Try running that command from a regular command prompt, or use Start-Process in the powershell.
    – Joe
    Nov 6, 2023 at 22:54

1 Answer 1

0

The problem is that you are trying to run a "text" (string), it does not actually get interpreted as a file/executable. You can fix that by including a . infront of the path.

Here is an example of how that would work:

. "C:\Program Files\MongoDB\Server\7.0\bin\mongod.exe" --dbpath="c:\data\db"
1
  • 1
    I don't think that's the problem. Quotation marks are necessary because of space in path. There should be no problem with correct interpretation in PowerShell CLI. Further more the dot you suggested has special role in PowerShell - Dot sourcing operator, but I think it's only for PowerShell scripts actually
    – R1cky
    Nov 4, 2023 at 19:47

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.