Mac OSX下手动安装MongoDB
1、从官网下载osx系统的mongodb包到目录/home/soft,并解压。 cd /home/softcurl -O http://downloads.mongodb.org/osx/mongodb-osx-x86_64-2.6.3.tgztar -zxvf mongodb-osx-x86_64-2.6.3.tgz 2、建立一个软连接,并创建一个数据库目录 ln -s ~/home/soft/mo
1、从官网下载osx系统的mongodb包到目录/home/soft,并解压。
cd /home/soft curl -O http://downloads.mongodb.org/osx/mongodb-osx-x86_64-2.6.3.tgz tar -zxvf mongodb-osx-x86_64-2.6.3.tgz
2、建立一个软连接,并创建一个数据库目录
ln -s ~/home/soft/mongodb-osx-x86_64-2.6.3 /usr/local/mongodb mkdir -p /usr/local/mongodb/database
3、创建mongod启动的配置文件,并手动启动mongodb试试看。
vi /usr/local/mongodb/mongod.conf
输入以下内容后保存退出
# MongoDB数据库存储目录 dbpath = /usr/local/mongodb/database # 日志目录 # logpath = /usr/local/var/log/mongodb.log # 绑定ip,限定只允许本地连接 bind_ip = localhost # 开启journaling journal = true # 开启REST rest = true # 启用更小的文件存储 # (可以节省开发环境下的空间) smallfiles = true
手动启动mongodb试试是否成功:
cd /usr/local/mongodb ./bin/mongod --config=./mongod.conf
看输出,应该OK了。control+c可以终止。
4、把mongodb相关命令加入shell
如果是用BASH,执行
echo 'export PATH=/usr/local/mongodb/bin:$PATH' >> ~/.bash_profile source ~/.bash_profile
我用的是oh-my-zsh, 修改~/.zshrc文件
vi ~/.zshrc
加入一行
export PATH=/usr/local/mongodb/bin:$PATH
保存并退出后,重新载入
source ~/.zshrc #然后就可以直接用mongod启动了 mongod --config=/usr/local/mongodb/mongod.conf
5、每次手动都要加入长长的参数,不想写成一个mongo_start.sh,干脆配置为随系统自动启动。
vi ~/Library/LaunchAgents/org.mongodb.mongod.plist
输入
<?xml version="1.0" encoding="UTF-8"?> <plist version="1.0"> <dict> <key>Label</key> <string>org.mongodb.mongod</string> <key>ProgramArguments</key> <array> <string>/usr/local/mongodb/bin/mongod</string> <string>--config=/usr/local/mongodb/mongod.conf</string> </array> <key>RunAtLoad</key> <true></true> <key>KeepAlive</key> <true></true> </dict> </plist>
然后注册到启动项
launchctl load -w ~/Library/LaunchAgents/org.mongodb.mongod.plist
从启动项取消,使用
launchctl unload -w ~/Library/LaunchAgents/org.mongodb.mongod.plist
完工!
参考资料:
http://mac-dev-env.patrickbougie.com/mongodb/
http://docs.mongodb.org/manual/tutorial/install-mongodb-on-os-x/
原文地址:Mac OSX下手动安装MongoDB, 感谢原作者分享。

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

AI Hentai Generator
Generate AI Hentai for free.

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics



"Jin Fan's resignation" is probably what all rice fans are most concerned about recently. Some people rushed to tell each other, muttering: "Xiaomi system can be saved", while others laughed and mocked: "No matter who replaces him, it will be the same." What’s more interesting is that the news of “Jin Fan’s resignation” did not come from Xiaomi officials or other insiders, but because some netizens discovered that Jin Fan’s Weibo had been cleared of all content. It looked like he was running away to avoid suspicion. , the same as clearing social accounts. Source: Weibo This news quickly attracted the attention of a large number of digital bloggers and media, including even authoritative media such as Phoenix.com, and it suddenly became the latest and hottest "melon" in the digital circle. Although Wang Hua, the head of Xiaomi's public relations department, later refuted the rumors, saying that Jin Fan had not resigned, but was "retreating" to work for

Ever since the Apple M4-powered OLED iPad Prolineuparrived, Apple Silicon aficionados have been eagerly awaiting the arrival of the M4 SoC on the Mac lineup. The M4 was undeniably a major leap forward in both compute and graphics performance - leapfr

According to industry insider Mark Gurman, Apple’s Apple Intelligence will be postponed to October. In other words, it will be pushed first on iOS18.1. Apple iPhone 16 is expected to be released in September, so Apple Intelligence will not be pre-installed. 1. Apple Intelligence Apple Intelligence is a personal intelligence system that uses a powerful generative model to provide new functions for iPhone, iPad and Mac to assist users in communicating, working and expressing. 2. Natural language understanding The large model embedded in Apple Intelligence has a deep understanding of the meaning of language.

Open AI’s ChatGPT Mac application is now available to everyone, having been limited to only those with a ChatGPT Plus subscription for the last few months. The app installs just like any other native Mac app, as long as you have an up to date Apple S

.NET 4.0 is used to create a variety of applications and it provides application developers with rich features including: object-oriented programming, flexibility, powerful architecture, cloud computing integration, performance optimization, extensive libraries, security, Scalability, data access, and mobile development support.

This article answers the questions about the official website entrance of "Sesame Open Door" and the Gate.io exchange entrance address. First of all, it is clear that "Sesame Open Door" is not a known formal trading platform, it may be an error message or an alias. As a well-known digital asset trading platform, Gate.io needs to be carefully searched to avoid phishing websites.

This article introduces how to configure MongoDB on Debian system to achieve automatic expansion. The main steps include setting up the MongoDB replica set and disk space monitoring. 1. MongoDB installation First, make sure that MongoDB is installed on the Debian system. Install using the following command: sudoaptupdatesudoaptinstall-ymongodb-org 2. Configuring MongoDB replica set MongoDB replica set ensures high availability and data redundancy, which is the basis for achieving automatic capacity expansion. Start MongoDB service: sudosystemctlstartmongodsudosys

This article describes how to build a highly available MongoDB database on a Debian system. We will explore multiple ways to ensure data security and services continue to operate. Key strategy: ReplicaSet: ReplicaSet: Use replicasets to achieve data redundancy and automatic failover. When a master node fails, the replica set will automatically elect a new master node to ensure the continuous availability of the service. Data backup and recovery: Regularly use the mongodump command to backup the database and formulate effective recovery strategies to deal with the risk of data loss. Monitoring and Alarms: Deploy monitoring tools (such as Prometheus, Grafana) to monitor the running status of MongoDB in real time, and
