The default administrative shell of MongoDB is a JavaScript shell. To start an administrative shell, enter bin directory of your MongoDB installation and execute mongo.exe file. If you are a complete beginner to NoSQL, I recommend you to have a quick look.
#HOW TO START MONGODB SERVER ON BACH HOW TO#
Then from the command line or within your batch script: mongo stop_mongod. Getting started with administrative shell. by Navindu Jayatilake How to get started with MongoDB in 10 minutesMongoDB is a rich document-oriented NoSQL database. You do not need to deploy or install MongoDB to complete this tutorial. Save the following snippet in stop_mongod.js file: db = connect("localhost:27017/admin") Īdjust the connection string if necessary. This tutorial walks you through inserting test data into a MongoDB database and querying that data using the documentations embedded web shell. Instead you will need to explicitly define the database in the connection (/dbname in the example above).Īlternately, you can also create a connection within the script: db2 = connect("server:27017/otherdbname") This command does not work in scripted mode. Open Command Prompt/Powershell as Administrator.Here is the official link about how to stop Mongodb properly : I'm automatically connected on the admin's collection and next, I just have to run the extinction. Maybe you already solved this question but here is what I do : mongo admin -eval "db.shutdownServer()" I'm not sure that's a proper way to do, sending a kill could probably cause damage to your mongo server, and you'll need to repair your database after in case of crash. How to stop mongodb server on Windows Im not sure thats a proper way to do, sending a kill could probably cause damage to your mongo server, and youll need to repair your database after in case of crash.