简体   繁体   English

在Windows 10上的cmd中启动MongoDB

[英]Start MongoDB in cmd on windows 10

I Want to install MongoDB and start it,I used this codes in cmd mongod --directoryperdb --dbpath C:\\mongodb\\data\\db --logpath C:\\mongodb\\log\\mongo,log --logappend --rest --install And For start this used this code in cmd net start MongoDB But I give this Error The service name is invalid. More help is available by typing NET HELPMSG 2185. 我想安装MongoDB并启动它,我在cmd mongod --directoryperdb --dbpath C:\\mongodb\\data\\db --logpath C:\\mongodb\\log\\mongo,log --logappend --rest --install使用了此代码mongod --directoryperdb --dbpath C:\\mongodb\\data\\db --logpath C:\\mongodb\\log\\mongo,log --logappend --rest --install并开始使用此命令在cmd net start MongoDB使用此代码,但我给出此错误The service name is invalid. More help is available by typing NET HELPMSG 2185. The service name is invalid. More help is available by typing NET HELPMSG 2185. How I Can fixed it?I'm searching any more time But don't find any Solution The service name is invalid. More help is available by typing NET HELPMSG 2185. 。我The service name is invalid. More help is available by typing NET HELPMSG 2185.如何解决?我正在搜索更多时间,但找不到任何解决方案

The problem is, the MongoDB service isn't installed, because you executed the install command without admin privilegues. 问题是,未安装MongoDB服务,因为您在没有管理员权限的情况下执行了install命令。

To solve this, open the start menu, enter powershell , right-click and select run as administrator . 要解决此问题,请打开开始菜单,输入powershell ,右键单击并选择以管理员身份运行 Now you should be able to run the install command. 现在,您应该可以运行install命令了。

mongod --directoryperdb --dbpath C:\mongodb\data\db --logpath C:\mongodb\log\mongo.log --logappend --rest --install

If you encounter the error again, after you tried to install the service as an admin user, you should have a look at the log file (in your case C:\\mongodb\\log\\mongo.log ) 如果再次遇到错误,则尝试以管理员用户身份安装服务后,应该查看日志文件(以您的情况为C:\\ mongodb \\ log \\ mongo.log

Btw. 顺便说一句。 there was an typo in your command for the logfile name (command instead of point for the filename) 您的命令中有一个日志文件名的错字(命令而不是指向文件名的点)

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

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