Http://www.mongodb.org/downloads
Download
Curl-o-L https://fastdl.mongodb.org/linux/mongodb-linux-i686-3.0.2.tgz
Unzip the installation
Tar-xvzf mongodb-liunix-xxxxx.tgz
Startup scripts
[email protected] bin]# cat start.sh
./mongod--dbpath/opt/mongodb-data/data--logpath/opt/mongodb-data/logs/mongodb.log--journal--fork
Set Password
> 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 ();
Password Setup is complete
The startup script is modified to
./mongod--dbpath/opt/mongodb-data/data--logpath/opt/mongodb-data/logs/mongodb.log--journal--fork--auth
Kill process Restart
[Email protected] 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
[Email protected] bin]# kill-9 10931
[Email protected] bin]# ps-ef|grep MONGO
Root 11042 10460 0 15:54 pts/0 00:00:00 grep MONGO
[Email protected] bin]# VI start.sh
[Email protected] bin]#./start.sh
About-to-fork child process, waiting until server was ready for connections.
Forked process:11047
Child process started successfully, parent exiting
Client Login
[Email protected] 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 Installation Notes