教程集 www.jiaochengji.com
教程集 >  Golang编程  >  golang教程  >  正文 mac下使用brew安装mongodb和配置

mac下使用brew安装mongodb和配置

发布时间:2022-03-23   编辑:jiaochengji.com
教程集为您提供mac下使用brew安装mongodb和配置等资源,欢迎您收藏本站,我们将为您提供最新的mac下使用brew安装mongodb和配置资源
<h2>mac安装homebrew</h2>

https://brew.sh/index_zh-cn.html
按照官网步骤即可。

<span class="img-wrap"></span>

<h2>使用brew安装mongodb</h2> <pre><code>brew install mongodb</code></pre>

<span class="img-wrap"></span>

说明已经使用mongodb安装成功。
安装目录为/usr/local/Cellar/mongodb/4.0.2

试着运行mongodb运行失败了。

<span class="img-wrap"></span>

发现默认mongodb 数据文件是放到根目录 data/db 文件夹下,如果没有这个文件,请自行创建.

<pre><code>mkdir -p /data/db</code></pre>

手动添加mongod到环境变量中:

<pre><code>nano ~/.bash_profile</code></pre> <pre><code>//添加mongodb安装目录到环境变量中 export PATH=/usr/local/Cellar/mongodb/4.0.2/bin:${PATH}}</code></pre>

让环境变量马上生效:

<pre><code>source ~/.bash_profile</code></pre>

修改mongodb配置文件,配置文件默认在 /usr/local/etc 下的 mongod.conf

<pre><code># Store data in /usr/local/var/mongodb instead of the default /data/db dbpath = /data/db # Append logs to /usr/local/var/log/mongodb/mongo.log logpath = /usr/local/var/log/mongodb/mongo.log logappend = true # Only accept local connections bind_ip = 127.0.0.1</code></pre>

再次运行mongodb

<span class="img-wrap"></span>
最后一行错误提示为刚刚新建的/data/db没有写入权限

给/data/db权限

<pre><code>sudo chown `id -u` /data/db</code></pre>

<span class="img-wrap"></span>

mongodb服务器启动起来啦,然后再去启动客户端

<span class="img-wrap"></span>

测试一下

<span class="img-wrap"></span>

到此这篇关于“mac下使用brew安装mongodb和配置”的文章就介绍到这了,更多文章或继续浏览下面的相关文章,希望大家以后多多支持JQ教程网!

您可能感兴趣的文章:
mac下使用brew安装mongodb和配置
mac系统下安装并开机启动mongodb
mac如何安装python3
mac上怎么安装python3
mac需要装python吗
怎么在mac上使用python
windows x86下安装mongodb且配置自动运行
Windows MongoDB4.2.0安装教程
mac下多个php版本切换(可操作版)
虚拟环境工具pyenv的安装,配置和使用,完美控制python版本

[关闭]
~ ~