網(wǎng)上很多安裝教程炼幔,借花獻(xiàn)佛了闪盔!
1.下載安裝包:
官網(wǎng):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.配置環(huán)境變量量蕊,~/.bash_profile添加如下:
export PATH=/usr/local/mongodb442/bin:$PATH
4.后臺(tái)啟動(dòng)運(yùn)行:
##/usr/local/var/mongodb 數(shù)據(jù)庫文件路徑
##/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.進(jìn)入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版本已經(jīng)沒有了【28017】端口的web界面价匠。所以你訪問:http://127.0.0.1:28017 會(huì)提示:
It looks like you are trying to access MongoDB over HTTP on the native driver port