新版Mongodb找不到mongo.exe的一种原因

mongodb正常安装后,修改环境变量,且mongod能轻松跑同,但是mongo命令无法被正确执行,回显如下:

mongo : 无法将“mongo”项识别为 cmdlet、函数、脚本文件或可运行程序的名称。请检查名称的拼写,如果包括路径,请确保路径正
确,然后再试一次。
所在位置 行:1 字符: 1
+ mongo
+ ~~~~~
    + CategoryInfo          : ObjectNotFound: (mongo:String) [], CommandNotFoundException
    + FullyQualifiedErrorId : CommandNotFoundException

前往安装目录下/bin目录中,没有mongo.exe文件,只有mongod和mongos,以及一个powershell命令脚本。

原因在于,mongodb6.0以后做出了重大改变,mongodb已经不再默认为你安装shell工具,因此需要安装一个额外的shell:Install mongosh — MongoDB Shell,这个工具被称为mongosh

前往mongoshell页面下载mongoshell,以后就用mongosh连接这个就好了。

记得把mongosh的安装目录也添加到环境变量,然后连接mongosh就好了。

PS C:\Windows\system32> mongosh
Current Mongosh Log ID: 63270cf93e2cd7827dabb1f7
Connecting to:          mongodb://127.0.0.1:27017/?directConnection=true&serverSelectionTimeoutMS=2000&appName=mongosh+1.5.4
Using MongoDB:          6.0.1
Using Mongosh:          1.5.4

For mongosh info see: https://docs.mongodb.com/mongodb-shell/


To help improve our products, anonymous usage data is collected and sent to MongoDB periodically (https://www.mongodb.com/legal/privacy-policy).
You can opt-out by running the disableTelemetry() command.

------
   The server generated these startup warnings when booting
   2022-09-18T20:19:33.889+08:00: Access control is not enabled for the database. Read and write access to data and configuration is unrestricted
------

------
   Enable MongoDB's free cloud-based monitoring service, which will then receive and display
   metrics about your deployment (disk utilization, CPU, operation statistics, etc).

   The monitoring data will be available on a MongoDB website with a unique URL accessible to you
   and anyone you share the URL with. MongoDB may use this information to make product
   improvements and to suggest MongoDB products and deployment options to you.

   To enable free monitoring, run the following command: db.enableFreeMonitoring()
   To permanently disable this reminder, run the following command: db.disableFreeMonitoring()
------

test> show dbs
admin   40.00 KiB
config  12.00 KiB
local   40.00 KiB
test>

  • 22
    点赞
  • 39
    收藏
    觉得还不错? 一键收藏
  • 4
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 4
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值