centos 6.5 mongodb3.11安裝記

來源:互聯網
上載者:User

標籤:

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

啟動指令碼

[[email protected] 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

殺死進程重新啟動

[[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 is ready for connections.
forked process: 11047
child process started successfully, parent exiting

用戶端登陸

[[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安裝記

相關文章

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.