Home  >  Article  >  Database  >  Ubuntu下单机安装MongoDB并测试

Ubuntu下单机安装MongoDB并测试

WBOY
WBOYOriginal
2016-06-07 17:05:511018browse

1.下载mongodb-linux-i686-1.8.2.tgz放在目录/home/nh/Downloads/下并解压得到mongodb-linux-i686-1.8.22.在/home/nh/Downloads/

1.下载mongodb-linux-i686-1.8.2.tgz放在目录/home/nh/Downloads/下并解压得到mongodb-linux-i686-1.8.2

2.在/home/nh/Downloads/mongodb-linux-i686-1.8.2下新建目录data1, 在 /home/nh/Downloads/mongodb-linux-i686-1.8.2/log1目录下新建文件log1.log 

3.@linuxidc:~/Downloads/mongodb-linux-i686-1.8.2/bin$ ./mongod -dbpath /home/nh/Downloads/mongodb-linux-i686-1.8.2/data1 -logpath /home/nh/Downloads/mongodb-linux-i686-1.8.2/log1/log1.log

4.@linuxidc:~/Downloads/mongodb-linux-i686-1.8.2/bin$ ./mongo 55Ubuntu:27017(在另一个命令行窗口中执行该命令,55ubuntu是你的主机名)

5.> db.test.save({a:1})(在shell中执行)

6.> db.test.findOne()(查看刚才的保存的文档{a: 1},会出现一下结果,说明可用)
{ "_id" : ObjectId("4e8ff5cd7a348a89a3b2dc3f"), "a" : 1 }

linux

Statement:
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