码迷,mamicode.com
首页 > 数据库 > 详细

centos 6.5 mongodb3.11安装记

时间:2015-04-19 01:15:09      阅读:171      评论:0      收藏:0      [点我收藏+]

标签:

下载地址

http://www.mongodb.org/downloads


下载

curl -O -L https://fastdl.mongodb.org/linux/mongodb-linux-i686-3.0.2.tgz

解压安装

tar -xvzf mongodb-Liunix-xxxxx.tgz

启动脚本

[root@a1 bin]# cat start.sh
./mongod --dbpath /opt/mongodb-data/data --logpath /opt/mongodb-data/logs/mongodb.log --journal --fork


设置密码

> use admin
switched to db admin
> db.createUser()
2015-04-18T15:39:05.402+0000 E QUERY    TypeError: Cannot read property ‘user‘ of undefined
    at DB.createUser (src/mongo/shell/db.js:1056:23)
    at (shell):1:4 at src/mongo/shell/db.js:1056
> db.createUser({user:"sa",pwd:"123",roles:[{role:"userAdminAnyDatabase",db:"admin"}]})
Successfully added user: {
 "user" : "sa",
 "roles" : [
  {
   "role" : "userAdminAnyDatabase",
   "db" : "admin"
  }
 ]
}
> show dbs
admin  0.078GB
local  0.078GB
> quit();


密码设置完

启动脚本修改为

./mongod --dbpath /opt/mongodb-data/data --logpath /opt/mongodb-data/logs/mongodb.log --journal --fork  --auth

杀死进程重新启动

[root@a1 bin]# ps -ef|grep mongo
root     10931     1  0 15:28 ?        00:00:11 ./mongod --dbpath /opt/mongodb-data/data --logpath /opt/mongodb-data/logs/mongodb.log --journal --fork
root     11038 10460  0 15:53 pts/0    00:00:00 grep mongo
[root@a1 bin]# kill -9 10931
[root@a1 bin]# ps -ef|grep mongo
root     11042 10460  0 15:54 pts/0    00:00:00 grep mongo
[root@a1 bin]# vi start.sh
[root@a1 bin]# ./start.sh
about to fork child process, waiting until server is ready for connections.
forked process: 11047
child process started successfully, parent exiting

客户端登陆

[root@a1 bin]# ./mongo --port 27017 -u sa -p 123 --authenticationDatabase admin
MongoDB shell version: 3.1.1
connecting to: 127.0.0.1:27017/test
>



centos 6.5 mongodb3.11安装记

标签:

原文地址:http://blog.csdn.net/alpa/article/details/45119469

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!