linux centos7 安装mongodb7.0.1 及 mongosh2.0.1

下载数据库并解压
wget https://fastdl.mongodb.org/linux/mongodb-linux-x86_64-rhel70-7.0.1.tgz
tar  -zxf mongodb-linux-x86_64-rhel70-7.0.1.tgz
#移动到/usr/local/mongo目录
mv mongodb-linux-x86_64-rhel70-7.0.1 /usr/local/mongodb
mongosh 命令行下载
#下载命令行工具 mongosh
wget https://downloads.mongodb.com/compass/mongosh-2.0.1-linux-x64.tgz
#解压命令行mongosh工具
tar -zxf mongosh-2.0.1-linux-x64.tgz 
mv mongosh-2.0.1-linux-x64 /usr/local/mongosh
安装启动

进入安装目录

cd /usr/local/mongodb

vim mongo.conf 编写MongoDB数据库配置文件

dbpath = /usr/local/mongodb/data
logpath = /usr/local/mongodb/logs/mongo.log
logappend = true
quiet = true
port = 27017
fork=true
bind_ip=0.0.0.0

创建数据存储目录 、日志存储目录

 mkdir data
 mkdir logs

启动mongo数据库 出现如下child process started successfully 字符表示mongodb进程启动成功

bin/mongod -f mongod.conf  
about to fork child process, waiting until server is ready for connections.
forked process: 12774
child process started successfully, parent exiting
客户端mongosh 连接验证
#连接数据库
/usr/local/mongosh/bin/mongosh --host  localhost --port 27017

test> show dbs;
admin   40.00 KiB
config  12.00 KiB
local   72.00 KiB
test    40.00 KiB
test> 

执行show dbs;能正确返回数据库列表就表示安装成功了。

你可能感兴趣的:(MongoDB,linux,mongodb)