Home Database Mysql Tutorial Mac OSX下手动安装MongoDB

Mac OSX下手动安装MongoDB

Jun 07, 2016 pm 04:37 PM
mac mongodb os download Install Official website

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
Copy after login

2、建立一个软连接,并创建一个数据库目录

ln -s ~/home/soft/mongodb-osx-x86_64-2.6.3 /usr/local/mongodb
mkdir -p /usr/local/mongodb/database
Copy after login

3、创建mongod启动的配置文件,并手动启动mongodb试试看。

vi /usr/local/mongodb/mongod.conf
Copy after login

输入以下内容后保存退出

# 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
Copy after login

手动启动mongodb试试是否成功:

cd /usr/local/mongodb
./bin/mongod --config=./mongod.conf
Copy after login

看输出,应该OK了。control+c可以终止。

4、把mongodb相关命令加入shell

如果是用BASH,执行

echo 'export PATH=/usr/local/mongodb/bin:$PATH' >> ~/.bash_profile
source ~/.bash_profile
Copy after login

我用的是oh-my-zsh, 修改~/.zshrc文件

vi ~/.zshrc
Copy after login

加入一行

export PATH=/usr/local/mongodb/bin:$PATH
Copy after login

保存并退出后,重新载入

source ~/.zshrc
#然后就可以直接用mongod启动了
mongod --config=/usr/local/mongodb/mongod.conf
Copy after login

5、每次手动都要加入长长的参数,不想写成一个mongo_start.sh,干脆配置为随系统自动启动。

vi ~/Library/LaunchAgents/org.mongodb.mongod.plist
Copy after login

输入

<?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>
Copy after login

然后注册到启动项

launchctl load -w ~/Library/LaunchAgents/org.mongodb.mongod.plist
Copy after login

从启动项取消,使用

launchctl unload -w ~/Library/LaunchAgents/org.mongodb.mongod.plist
Copy after login

完工!

参考资料:

http://mac-dev-env.patrickbougie.com/mongodb/

http://docs.mongodb.org/manual/tutorial/install-mongodb-on-os-x/

Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

AI Hentai Generator

AI Hentai Generator

Generate AI Hentai for free.

Hot Article

R.E.P.O. Energy Crystals Explained and What They Do (Yellow Crystal)
4 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. Best Graphic Settings
4 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. How to Fix Audio if You Can't Hear Anyone
4 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. Chat Commands and How to Use Them
4 weeks ago By 尊渡假赌尊渡假赌尊渡假赌

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

Mi fans criticize, Xiaomi stays, The Paper OS can't live without Jin Fan? Mi fans criticize, Xiaomi stays, The Paper OS can't live without Jin Fan? Aug 07, 2024 pm 06:16 PM

"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

MacBook Pro, iMac to get the M4 upgrade later this year followed by MacBook Air in spring of 2025, claims reliable tipster MacBook Pro, iMac to get the M4 upgrade later this year followed by MacBook Air in spring of 2025, claims reliable tipster Jun 25, 2024 am 06:35 AM

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

Apple iPhone 16 is no longer pre-installed with Apple Intelligence Apple iPhone 16 is no longer pre-installed with Apple Intelligence Jul 30, 2024 pm 01:18 PM

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.

ChatGPT is now available for macOS with the release of a dedicated app ChatGPT is now available for macOS with the release of a dedicated app Jun 27, 2024 am 10:05 AM

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

What is the use of net4.0 What is the use of net4.0 May 10, 2024 am 01:09 AM

.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.

Sesame Open Door Official Website Entrance gate.io Exchange Access Address Sesame Open Door Official Website Entrance gate.io Exchange Access Address Feb 28, 2025 am 11:03 AM

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.

How to configure MongoDB automatic expansion on Debian How to configure MongoDB automatic expansion on Debian Apr 02, 2025 am 07:36 AM

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

How to ensure high availability of MongoDB on Debian How to ensure high availability of MongoDB on Debian Apr 02, 2025 am 07:21 AM

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

See all articles