前言
MongoDB 是一个基于分布式文件存储的数据库,旨在为 web 应用提供可扩展的高性能数据存储解决方案。本文主要介绍的是关于在mac中安装卸载mongoDB数据库的方法,更多关于mongoDB的使用大家可以参考这篇文章: http://HdhCmsTesttuohang.net/article/63166.html
(一) mongodb 安装
mongodb 数据库的安装有两种方法。
一种是使用命令行安装,第二种是使用HomeBrew 安装,我按照第二种方式安装。
1.更新Homebrew的package数据库:
1 |
$ brew update |
2.安装 mongodb
1 |
$ brew install mongodb |
成功后出现下面一段描述:
1 2 3 4 5 6 7 8 9 10 11 12 |
Updating Homebrew...
==> Downloading https: //homebrew .bintray测试数据 /bottles/mongodb-3 .4.4.sierra.bottle Already downloaded: /Users/liangma/Library/Caches/Homebrew/mongodb-3 .4.4.sierra.bottle. tar .gz ==> Pouring mongodb-3.4.4.sierra.bottle. tar .gz ==> Using the sandbox ==> Caveats To have launchd start mongodb now and restart at login: brew services start mongodb Or, if you don't want /need a background service you can just run: mongod --config /usr/local/etc/mongod .conf ==> Summary |
3.查看安装列表
1 2 3 4 |
$ brew list
mongodb (已经存在) ... |
4.启动mongodb
1 |
$ mongod --config /usr/local/etc/mongod .conf |
5.连接mongodb service
1 |
$ mongo |
6.使用
查看所以数据库
1 2 3 4 5 6 |
> show dbs
admin 0.000GB data_person_info 0.000GB local 0.000GB test 0.000GB |
创建数据库
1 2 3 |
> use data_person_info
switched to db data_person_info |
查看当前数据库
1 2 3 |
> db
data_person_info |
添加表数据(文档)
1 2 3 |
> db.data_person_info.insert({ 'id' : '0001' , 'name' : 'bojue' , 'age' : '24' })
WriteResult({ "nInserted" : 1 }) |
查看表数据(文档)
1 2 3 |
> db.data_person_info. find ()
{ "_id" : ObjectId( "59f4c3396564b89187361bfd" ), "id" : "0001" , "name" : "bojue" , "age" : "24" } |
(二) mongodb 卸载
1 2 3 |
$ brew uninstall mongodb
$ brew list (已经不存在 mongodb) |
总结
以上就是这篇文章的全部内容了,希望本文的内容对大家的学习或者工作具有一定的参考学习价值,如果有疑问大家可以留言交流,谢谢大家对服务器之家的支持。
原文链接:http://HdhCmsTestjianshu测试数据/p/f52a63bd7e82
查看更多关于Mac中mongoDB的安装与卸载步骤详解的详细内容...