简体   繁体   English

如何在终端中重启 mongodb?

[英]how to restart mongodb in terminal?

I installed mongodb in VS code by npm install mongodb .我通过 npm 在 VS 代码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.我再次从官方网站下载了 mongodb 并将其安装为 windows 服务,因为我不知道使用 npm 安装在npm中是否足够。 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.现在它不起作用,因为我与 mongoose 的数据库连接失败并且本地主机的 27017 端口中没有任何运行。 Seems like server stopped.好像服务器停止了。

how to restart mongodb server?如何重启 mongodb 服务器? what's the CLI/terminal command etc for that?什么是 CLI/终端命令等?

[![Mongodb Services][1]][1] [![Mongodb 服务][1]][1]

Go to services via start button and check for the mongodb services shown in below pic. Go 通过启动按钮连接到服务,并检查下图中显示的 mongodb 服务。 And rest steps you can follow which @apoorva has mentioned.您可以遵循@apoorva 提到的 rest 步骤。 [1]: https://i.stack.imgur.com/OgbRP.png [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)如果您将 MongoDB 安装为 Windows 服务 MongoDB 服务在安装成功后启动。(请检查以下路径)

To begin using MongoDB, connect a mongo.exe shell to the running MongoDB instance.要开始使用 MongoDB,请将 mongo.exe shell 连接到正在运行的 MongoDB 实例。 Either:任何一个:

From Windows Explorer/File Explorer, go to C:\Program Files\MongoDB\Server\4.4\bin\ directory and double-click on mongo.exe.从 Windows Explorer/File Explorer、go 到 C:\Program Files\MongoDB\Server\4.4\bin\ 目录并双击 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 : 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.此外,您首先需要启动 mongodb 守护程序以侦听连接,然后您应该使用 mongoose 进行连接。

On debian/ubuntu在 debian/ubuntu 上

sudo service mongod restart sudo 服务 mongod 重启

Open a mongo shell and execute,打开一个mongo shell 并执行,

use admin
db.shutdownServer()

You may start again with mongod .您可以从mongod重新开始。

Learn more here, https://docs.mongodb.com/manual/tutorial/manage-mongodb-processes/#StartingandStoppingMongo-SendingshutdownServer%28%29messagefromthemongoshell在此处了解更多信息, https://docs.mongodb.com/manual/tutorial/manage-mongodb-processes/#StartingandStoppingMongo-SendingshutdownServer%28%29messagefromthemongoshell

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM