设为首页 加入收藏

TOP

centos6.5 mongodb3.11安装记
2015-07-24 11:11:02 来源: 作者: 【 】 浏览:2
Tags:centos6.5 mongodb3.11 安装

下载地址

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
>

??

?

】【打印繁体】【投稿】【收藏】 【推荐】【举报】【评论】 【关闭】 【返回顶部
分享到: 
上一篇机器学习___ELM 下一篇关于orderby的一些用法

评论

帐  号: 密码: (新用户注册)
验 证 码:
表  情:
内  容:

·About - Redis (2025-12-26 08:20:56)
·Redis: A Comprehens (2025-12-26 08:20:53)
·Redis - The Real-ti (2025-12-26 08:20:50)
·Bash 脚本教程——Li (2025-12-26 07:53:35)
·实战篇!Linux shell (2025-12-26 07:53:32)