I installed mongodb in VS code by npm install mongodb
. And again I downloaded mongodb from official website and installed it as a windows service since I don't know if installing in vscode with npm
is enough. It worked for a while.
and now it doesn't work as my database connection with mongoose fails and nothing is running in 27017 port in localhost. Seems like server stopped.
how to restart mongodb server? what's the CLI/terminal command etc for that?
[![Mongodb Services][1]][1]
Go to services via start button and check for the mongodb services shown in below pic. And rest steps you can follow which @apoorva has mentioned. [1]: https://i.stack.imgur.com/OgbRP.png
If You Installed MongoDB as a Windows Service The MongoDB service is started upon successful installation.(please check on the below path)
To begin using MongoDB, connect a mongo.exe shell to the running MongoDB instance. Either:
From Windows Explorer/File Explorer, go to C:\Program Files\MongoDB\Server\4.4\bin\ directory and double-click on mongo.exe.
Or, open a Command Interpreter with Administrative privileges and run:
"C:\Program Files\MongoDB\Server\4.4\bin\mongo.exe"
for more details check. : https://treehouse.github.io/installation-guides/windows/mongo-windows.html
Also, you first need to start the mongodb daemon for your connections to listen then you should connect using mongoose.
On debian/ubuntu
sudo service mongod restart
Open a mongo shell and execute,
use admin
db.shutdownServer()
You may start again with mongod
.
Learn more here, https://docs.mongodb.com/manual/tutorial/manage-mongodb-processes/#StartingandStoppingMongo-SendingshutdownServer%28%29messagefromthemongoshell
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.