Linux安装mongodb
<h2 id="一安装mongodb">一、安装mongoDB</h2><pre><code>##1.进入指定的目录位置
cd /usr/local
##2.创建mongodb文件夹
mkdir mongodb
##3.进入创建的mongodb文件夹
cd mongodb
##4.wget下载mongoDb安装包
wgethttps://fastdl.mongodb.org/linux/mongodb-linux-x86_64-4.0.7.tgz
##5.解压下载的mongoDb安装包
tar -zxvfmongodb-linux-x86_64-4.0.7.tgz
##6.进入解压的mongodb-linux-x86_64-4.0.7文件
cd mongodb-linux-x86_64-4.0.7
##7.创建logs和datas文件夹
mkdir -p logs datas
##8.给mongodb-linux-x86_64-4.0.7文件授权
chmod777 /usr/local/mongodb/mongodb-linux-x86_64-4.0.7
</code></pre>
<h2 id="二mongodb配置">二、mongoDB配置</h2>
<pre><code>1.cd bin
2.vim mongodb.conf
</code></pre>
<pre><code>## 数据目录
dbpath = /usr/local//mongodb/mongodb-linux-x86_64-4.0.7/datas
## 日志文件
logpath =/usr/local//mongodb/mongodb-linux-x86_64-4.0.7/logs/mongodb.log
## 端口号:默认27017
port = 27017
## 后台启动
fork = true
## 可外网访问
bind_ip=0.0.0.0
</code></pre>
<h2 id="三启动服务端">三、启动服务端</h2>
<pre><code>方式1: ./mongod --config mongodb.conf
方式2: ./mongod -f mongodb.conf
</code></pre>
<h2 id="四启动客户端">四、启动客户端</h2>
<p><code> ./mongo</code></p>
<h2 id="五停止mongodb">五、停止mongoDB</h2>
<p><code>./mongod -shutdown -dbpath=/usr/local/mongodb/data</code></p>
<h2 id="六开机启动配置">六、开机启动配置</h2>
<pre><code>##设置权限
chmod 754 mongodb.service
##开机启动
systemctl enable mongodb.service
##启动服务
systemctl start mongodb.service
##关闭服务
systemctl stop mongodb.service
##加入环境变量
vim /etc/profile
#在最后加入
export PATH="/usr/local/mongodb/mongodb/bin:$PATH"
#保存后执行
source /etc/profile
</code></pre>
<h2 id="七mongodb错误的总结">七、MongoDB错误的总结</h2>
<ul>
<li>child process failed, exited with error number 1<br>
<img src="https://img2022.cnblogs.com/blog/2156747/202210/2156747-20221009112308322-1374365518.png" alt="" loading="lazy"></li>
<li>child process failed, exited with error number 48<br>
<img src="https://img2022.cnblogs.com/blog/2156747/202210/2156747-20221009112348878-1140125582.png" alt="" loading="lazy"></li>
<li>child process failed, exited with error number 100<br>
<img src="https://img2022.cnblogs.com/blog/2156747/202210/2156747-20221009112425256-995397415.png" alt="" loading="lazy"></li>
</ul>
</div>
<div id="MySignature" role="contentinfo">
古今成大事者,不唯有超世之才,必有坚韧不拔之志!<br><br>
来源:https://www.cnblogs.com/songweipeng/p/15223192.html
頁:
[1]