-
Mongodb的安装与启动
-
----------------------------------------------------------------------------
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.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
-
-
-
-
Linux下Mongodb安装和启动配置
最新推荐文章于 2024-10-14 15:37:21 发布