E QUERY [thread1] SyntaxError: missing ; before statement @(shell):1:6

after open second terminal, type mongo for connecting to DB. If I want to shutdown mongod from our second shell with mongo admin --eval 'db.shutdownServer()' the command return a SyntaxError.

SyntaxError: missing ; before statement @(shell):1:6

What is missing on it?

Hey @daniel_71573

This error is because you are trying to run that command inside a mongo shell. Try to exit out of the shell and run the command or just run db.shutdownServer() from inside the shell.


Opt 1- exit mongo shell (Ctrl+C or type ‘quit()’) then run command directly on vagrant shell:
vagrant@m103:~$ mongo admin --eval 'db.shutdownServer()'
Opt 2- on mongo shell switch to admin db then run command there:
> use admin
> db.shutdownServer({ shutdown: 1, force: true })