linux-ubuntu18 mongodb 安装、卸载、操作

一、安装

ubuntu默认安装mongodb的版本为3.6版本
安装:

$sudo apt install mongodb-org

如需安装高版本执行以下命令,如版本4

$sudo apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv 9DA31620334BD75D9DCB49F368818C72E52529D4
$echo "deb [ arch=amd64 ] https://repo.mongodb.org/apt/ubuntu bionic/mongodb-org/4.0 multiverse" | sudo tee /etc/apt/sources.list.d/mongodb.list
$sudo apt update

之后安装mongodb

$sudo apt install mongodb-org

如需安装自定义版本执行

$sudo apt install mongodb-org=4.0.23

二、卸载

卸载比较彻底的命令

$sudo apt-get purge --auto-remove mongodb

三、操作

导出表

mongoexport --host 127.0.0.1:27017 --username test --password test123 --authenticationDatabase admin --db testdb --collection testcollection --type json  --out testcollection.json
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容