Error when running mongo admin --eval

MongoDB Enterprise > mongo admin --eval ‘db.shutdownServer()’
2019-11-14T19:12:29.531+0000 E QUERY [thread1] SyntaxError: missing ; before statement @(shell):1:6

Any help?

I’m trying to complete Chapter 1: The Mongod. This command was copied from the lecture notes provided.

@Scott_86953 please edit your thread and link it to the relevant course to get relevant responses.

Good man! :+1:

Now for your problem! You need to run the command outside the mongo shell.

Note the instructions say to connect to the mongo shell…

Now, After following your instruction, I was able to shutdown the server when I exited the shell and issued the shut down command, as show in the below screen shot. I did this a couple of times to get the hang of it… now when I tried it a third time, the database is not shutting down.

Here is the command I run at the command prompt.

Here is the screen of the mongod that is running after I issue the above command…

Yeah, that’s wrong. You can’t issue mongo inside a mongo shell. However, I don’t think both commands are connected… compare it with the video.
However, here’s an alternative way of shutting down the server from inside a mongo shell:

use admin

Are you sure it didn’t shutdown? Try it again, run show dbs and let’s see the result.

1 Like

How do you interpret the following screen shot?

It’s shutdown! :beer: :nerd_face:

Ignore the prompt you’re seeing. If you can’t run anything from inside the shell then the server is down.

1 Like