- Mongodb的安装与启动
- 下载链接: http://www.mongodb.org/downloads----------------------------------------------------------------------------
Linux安装第一步:下载安装包下载版本:2.0.2-rc2下载链接: http://fastdl.mongodb.org/linux/mongodb-linux-x86_64-2.0.4.tgz首先在linux中解压缩安装程序通过命令操作:解压:[root@localhost soft]# tar -zxvf mongodb-linux-i686-2.0.1.tgz解压过程如下:
mongodb-linux-i686-2.0.1/
mongodb-linux-i686-2.0.1/THIRD-PARTY-NOTICES
mongodb-linux-i686-2.0.1/GNU-AGPL-3.0
mongodb-linux-i686-2.0.1/README
mongodb-linux-i686-2.0.1/bin/
mongodb-linux-i686-2.0.1/bin/mongofiles
mongodb-linux-i686-2.0.1/bin/mongostat
mongodb-linux-i686-2.0.1/bin/bsondump
mongodb-linux-i686-2.0.1/bin/mongos
mongodb-linux-i686-2.0.1/bin/mongotop
mongodb-linux-i686-2.0.1/bin/mongodump
mongodb-linux-i686-2.0.1/bin/mongoimport
mongodb-linux-i686-2.0.1/bin/mongosniff
mongodb-linux-i686-2.0.1/bin/mongo
mongodb-linux-i686-2.0.1/bin/mongod
mongodb-linux-i686-2.0.1/bin/mongoexport
mongodb-linux-i686-2.0.1/bin/mongorestore
我们把 mongodb-linux-i686-2.0.2-rc2重命名为mongodb
mv mongodb-linux-x86_64-2.0.4.tgz mongodb
- 然后定位到mongodb/bin目录中
cd /usr/local/mongodb/bin
- 启动命令 :
- ./mongod --dbpath=/usr/local/mongodb/mongodb_db --logpath=/usr/local/mongodb/mongodb_logs/mongodb.log --logappend&
- 检查mogodb端口
netstat -lanp | grep 27017
- 使用默认账号,添加自己的账号
./mongo
MongoDB shell version: 2.0.4
connecting to: test
> db.system.users.find()
> db.system.users.find();
> use mongo_test
switched to db mongo_test
> db.createCollection("test")
{ "ok" : 1 }
//使用默认账号
> use admin
switched to db admin
//添加账号
> db.adduser('cl','cl')
//读写授权
> db.auth("zhixian","Zhixian123")
//添加成功
Mon Jun 20 22:43:13 TypeError: db.adduser is not a function (shell):1
//测试
> db.addUser('cl','cl')
{ "n" : 0, "connectionId" : 1, "err" : null, "ok" : 1 }
{
"user" : "cl",
"readOnly" : false,
"pwd" : "1b8c3505b26a25291393e900e8c89f29",
"_id" : ObjectId("5768018f62752737d5e06717")
}
> show collections
system.indexes
system.users
> db.system.users.find()
{ "_id" : ObjectId("5768018f62752737d5e06717"), "user" : "cl", "readOnly" : false, "pwd" : "1b8c3505b26a25291393e900e8c89f29" }
> exit
bye
linux下开机启动mongodb
vim /etc/rc.local
- 最后一行加入
/usr/local/mongodb/bin/mongod --dbpath=/usr/local/mongodb/mongodb_db --fork --port 27017 --logpath=/usr/local/mongodb/mongodb_logs/mongodb.log--logappend --auth
标签:bin,Mongodb,Linux,db,i686,mongodb,linux,2.0,安装 From: https://blog.51cto.com/u_809530/8257254