【mongoDB】ubuntu安装mongosh

news/2024/9/29 17:32:46

一、场景

    测试过程需要增删改查查询MongoDB数据,并对比结果

 

二、官网

    https://www.mongodb.com/try/download/shell

选择对应的系统和版本,下载即可

 

三、安装

sudo dpkg -i mongodb-mongosh_2.2.6_amd64.deb

检查安装结果

$ mongosh --help$ mongosh [options] [db address] [file names (ending in .js or .mongodb)]Options:-h, --help                                 Show this usage information-f, --file [arg]                           Load the specified mongosh script--host [arg]                           Server to connect to--port [arg]                           Port to connect to--build-info                           Show build information--version                              Show version information--quiet                                Silence output from the shell during the connection process--shell                                Run the shell after executing files--nodb                                 Don't connect to mongod on startup - no 'db address' [arg] expected--norc                                 Will not run the '.mongoshrc.js' file on start up--eval [arg]                           Evaluate javascript--json[=canonical|relaxed]             Print result of --eval as Extended JSON, including errors--retryWrites[=true|false]             Automatically retry write operations upon transient network errors (Default: true)Authentication Options:-u, --username [arg]                       Username for authentication-p, --password [arg]                       Password for authentication--authenticationDatabase [arg]         User source (defaults to dbname)--authenticationMechanism [arg]        Authentication mechanism--awsIamSessionToken [arg]             AWS IAM Temporary Session Token ID--gssapiServiceName [arg]              Service name to use when authenticating using GSSAPI/Kerberos--sspiHostnameCanonicalization [arg]   Specify the SSPI hostname canonicalization (none or forward, available on Windows)--sspiRealmOverride [arg]              Specify the SSPI server realm (available on Windows)TLS Options:--tls                                  Use TLS for all connections--tlsCertificateKeyFile [arg]          PEM certificate/key file for TLS--tlsCertificateKeyFilePassword [arg]  Password for key in PEM file for TLS--tlsCAFile [arg]                      Certificate Authority file for TLS--tlsAllowInvalidHostnames             Allow connections to servers with non-matching hostnames--tlsAllowInvalidCertificates          Allow connections to servers with invalid certificates--tlsCertificateSelector [arg]         TLS Certificate in system store (Windows and macOS only)--tlsCRLFile [arg]                     Specifies the .pem file that contains the Certificate Revocation List--tlsDisabledProtocols [arg]           Comma separated list of TLS protocols to disable [TLS1_0,TLS1_1,TLS1_2]--tlsUseSystemCA                       Load the operating system trusted certificate list--tlsFIPSMode                          Enable the system TLS library's FIPS mode
API version options:--apiVersion [arg]                     Specifies the API version to connect with--apiStrict                            Use strict API version mode--apiDeprecationErrors                 Fail deprecated commands for the specified API versionFLE Options:--awsAccessKeyId [arg]                 AWS Access Key for FLE Amazon KMS--awsSecretAccessKey [arg]             AWS Secret Key for FLE Amazon KMS--awsSessionToken [arg]                Optional AWS Session Token ID--keyVaultNamespace [arg]              database.collection to store encrypted FLE parameters--kmsURL [arg]                         Test parameter to override the URL of the KMS endpointDB Address Examples:foo                                    Foo database on local machine192.168.0.5/foo                        Foo database on 192.168.0.5 machine192.168.0.5:9999/foo                   Foo database on 192.168.0.5 machine on port 9999mongodb://192.168.0.5:9999/foo         Connection string URI can also be used
File Names:A list of files to run. Files must end in .js and will exit after unless --shell is specified.Examples:Start mongosh using 'ships' database on specified connection string:$ mongosh mongodb://192.168.0.5:9999/ships
For more information on usage: https://docs.mongodb.com/mongodb-shell.

 

 四、连接MongoDB服务

mongosh mongodb://{ip}:{port}/{database}

需要认证的服务就加上用户名密码

mongodb://{username}:{password}@{ip}:{port}/{database}?authSource=admin

然后就可以连接上了

 

一顿操作增删改查即可

 

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.hjln.cn/news/45386.html

如若内容造成侵权/违法违规/事实不符,请联系我们进行投诉反馈,一经查实,立即删除!

相关文章

03-Loki 日志监控

1 Loki 1.1 简介 功能强大;轻量级,可以在配置更低的设备上部署;完全契合现代化部署方式; github Loki是受Prometheus启发的水平可扩展、高可用、多租户日志聚合系统。它的设计非常具有成本效益且易于操作。它不索引日志的内容,而是索引每个日志流的一组标签。 1.2 优点 与…

基于软件在环的飞控机建模仿真

​安全关键系统(Safety-Critical System,SCS)是指由于某些行为或组合行为能够引发整体系统失效,继而导致财物损失、人员受伤等严重影响的系统,诸多安全关键领域如航空航天、核电系统、医疗设备、交通运输等领域的系统都属于安全关键系统,而这些系统中大部分核心功能是由软…

AIRIOT助力全国大学生物联网设计竞赛高校巡回宣讲会

为了进一步增强赛事影响力、促进校企交流与合作、推动物联网教育与创新,由2024全国大学生物联网设计竞赛组委会主办全国巡回技术讲座暨赛题宣讲活动于2024年5月在湖南大学、深圳技术大学、四川大学、武汉大学、西安交通大学、郑州大学、中国石油大学、山东商业职业技术学院全国…

2024出游记录

日常记录 2024-01-08 凤华红汤牛肉面(古城小街)菜品 星级(1-5) 评价 价格拉面 4.5 胡萝卜很脆,但是削的粗细不一导致口感不好,汤底非常浓郁有很明显的肉香味,是那种单尝能喝一整碗的汤底,面条没好巧嫂子筋道,但也还行中规中矩 12小 14大总结 4.5 环境一般,小店很挤,辣椒也很…

EF 初始化数据库

初始化数据库命令: 删除Migrations文件夹自己重新生成请使用 Add-Migration Update-database 不删除直接更新请使用 Update-database 设置需要初始化的项目为启动项,并配置默认项目为初始化项目看到 Done 后就成功了 参考文档: https://www.cnblogs.com/djd66/p/16899185.ht…

NAS服务器两块硬盘损坏无法访问恢复实例

状态灯是黄灯,DISC4也是亮黄灯,机器一直在报警群辉型号DS415+,是一种典型的硬盘损坏的情况,这是一台四盘位的一个群辉NAS,第一时间把每个硬盘取下来编个编号,WD的红盘也就是nasVR专用硬盘,型号是WD401F2X的,生产日期有三块是2015年,有一块是比较新。差不多三年前就是损…

Confluence是否免费?获取方法及可能问题

本文将详细介绍Confluence产品指南。根据Atlassian官方信息,可以确定的是 Confluence 并不免费,但为10人以下团队提供了免费版本。免费版可以使用不限量的页面、空间,但只有2GB的存储空间和3个活动白板。但国内有不少公司通过使用破解版的方式来免费使用Cofluence。下面本文…

MQTT如何使用

1. 下载并安装客户端 访问路径:https://mqttx.app/zh 切换成中文 2. 配置环境链接 开发环境 服务器地址:emqdev.zxy168.cn,端口:18830 用户名:test,密码:test 测试环境:emqx1.zxy168.cn 生产环境:emqx1.xbzl.cc3. 订阅消息 订阅硬件发来的消息 Topic填Gateway/XBDGN…