centos 6.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
>
郑重声明:本站内容如果来自互联网及其他传播媒体,其版权均属原媒体及文章作者所有。转载目的在于传递更多信息及用于网络分享,并不代表本站赞同其观点和对其真实性负责,也不构成任何其他建议。