mac下安装mongodb
2021-01-05 本文已影响0人
牙齿不帅
网上很多安装教程,借花献佛了!
1.下载安装包:
官网:https://www.mongodb.com/try/download/community
2.解压gz到 /usr/local/ :
cyldeMacBook-Pro:local neu-cyl$ sudo tar -zxvf mongodb-macos-x86_64-4.4.2.tgz
cyldeMacBook-Pro:local neu-cyl$ mv mongodb-macos-x86_64-4.4.2 mongodb442
3.配置环境变量,~/.bash_profile添加如下:
export PATH=/usr/local/mongodb442/bin:$PATH
4.后台启动运行:
##/usr/local/var/mongodb 数据库文件路径
##/usr/local/var/log/mongodb/mongo.log log路径
cyldeMacBook-Pro:local neu-cyl$ mongod --dbpath /usr/local/var/mongodb --logpath /usr/local/var/log/mongodb/mongo.log --fork
5.查看:
cyldeMacBook-Pro:mongodb442 neu-cyl$ ps -ef|grep mongodb
501 57259 1 0 11:06上午 ?? 0:01.24 mongod --dbpath /usr/local/var/mongodb --logpath /usr/local/var/log/mongodb/mongo.log --fork
501 57267 477 0 11:06上午 ttys008 0:00.00 grep mongodb
6.进入mongo。
cyldeMacBook-Pro:mongodb442 neu-cyl$ mongo
MongoDB shell version v4.4.2
connecting to: mongodb://127.0.0.1:27017/?compressors=disabled&gssapiServiceName=mongodb
Implicit session: session { "id" : UUID("08dd029c-042f-4e4b-a60f-7876b1bd1332") }
MongoDB server version: 4.4.2
---
The server generated these startup warnings when booting:
2021-01-05T11:06:26.983+08:00: Access control is not enabled for the database. Read and write access to data and configuration is unrestricted
2021-01-05T11:06:26.984+08:00: This server is bound to localhost. Remote systems will be unable to connect to this server. Start the server with --bind_ip <address> to specify which IP addresses it should serve responses from, or with --bind_ip_all to bind to all interfaces. If this behavior is desired, start the server with --bind_ip 127.0.0.1 to disable this warning
2021-01-05T11:06:26.985+08:00: Soft rlimits too low
2021-01-05T11:06:26.985+08:00: currentValue: 256
2021-01-05T11:06:26.985+08:00: recommendedMinimum: 64000
---
---
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()
---
>
最后,mongodb4.4版本已经没有了【28017】端口的web界面。所以你访问:http://127.0.0.1:28017 会提示:
It looks like you are trying to access MongoDB over HTTP on the native driver port