欢迎投稿

今日深度:

centos 6.5 mongodb3.11安装记,centosmongodb3.11

centos 6.5 mongodb3.11安装记,centosmongodb3.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
>



www.htsjk.Com true http://www.htsjk.com/shujukunews/7597.html NewsArticle centos 6.5 mongodb3.11安装记,centosmongodb3.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 启动脚本 [...
评论暂时关闭