MongoDB安装

来源:互联网 发布:黄金交易行情软件 编辑:程序博客网 时间:2024/06/13 10:12

1.MongoDB 下载

http://www.mongodb.org/downloads

2.下载完安装包,并解压 tgz,目录提前创建

curl -O https://fastdl.mongodb.org/linux/mongodb-linux-x86_64-3.0.6.tgz    # 下载tar -zxvf mongodb-linux-x86_64-3.0.6.tgz                                   # 解压mv  mongodb-linux-x86_64-3.0.6/ /usr/local/mongodb                         # 将解压包拷贝到指定目录
3.添加环境变量

export PATH= /usr/local/mongodb/bin:$PATH
4.主要文件夹和目录
mongod --mongoDB执行程序
mongo --连接mongoDB数据库客户端
mongoimport --导入
mongoexport --导出
mongodump --备份
mongorestore --修复
mongostat --状态

5.手动创建文件夹
mkdir mongodb_simple
cd mongodb_simple
mkdir data
mkdir log
mkdir conf
mkdir bin

6.新建配置文件
cdconf
vim mongod.conf
port=27017
dbpath=data
logpath=log/mongod.log
fork=true --在linux启动后台进程,windows下无效(开发下使用)

7.启动指定的配置文件

./bin/mongod -f conf/mongod.conf

$ cd /usr/local/mongodb/bin$ ./mongo
8.启动
numactl --interleave=all bin/mongod -f conf/mongod.conf

9.开始进入
./bin/mongo 127.0.0.1:27017
show dbs
use imooc
db.dropDatabase() --删除
show dbs
use imooc
表是一个集合
db.imooc_collection.insert({x:1})
show dbs
show collections
db.imooc_collection.find()


0 0
原创粉丝点击