mongoDB 3.0.3 以上GUI 串連認證問題

來源:互聯網
上載者:User

標籤:

因為項目要用到mongoDB,今天嘗試搭建了一下。

首先mongo還是很好裝的,yum 或者手動下載都可以,我是yum安裝的最新版本的3.0.4。

主要是安裝完成之後,需要安裝一個GUI管理工具,我嘗試了很多,都是差不多的。最後選擇使用Robomongo,因為這個GUI工具在Linux、MAC、Windows上都有版本。

我在centos 上安裝,裝好之後修改 /etc/mongod.conf檔案

1 port = 27017 2 3 auth = true4 5 bind_ip = 0.0.0.0

修改這三行。

之後的問題就出在串連認證上了 ,mongoDB 3.0以後的版本認證變得複雜起來,串連工具都不能串連上,必須修改認證版本

> use admin switched to db admin >  var schema = db.system.version.findOne({"_id" : "authSchema"}) > schema.currentVersion = 3 3 > db.system.version.save(schema) WriteResult({ "nMatched" : 1, "nUpserted" : 0, "nModified" : 1 }) 

在修改完成之後再建立使用者。下面附帶建立資料庫使用者的shell:

1 建立一個root使用者:

use admindb.createUser(    {      user: "superuser",      pwd: "12345678",      roles: [ "root" ]    })

2 建立admin使用者

use admindb.createUser(  {    user: "siteUserAdmin",    pwd: "password",    roles: [ { role: "userAdminAnyDatabase", db: "admin" } ]  })

3 建立具體資料庫的使用者

use recordsdb.createUser(  {    user: "recordsUserAdmin",    pwd: "password",    roles: [ { role: "userAdmin", db: "records" } ]  })

最後都要認證一下

db.auth("user", "pwd")

返回1代表成功,0代表失敗。

mongoDB 3.0.3 以上GUI 串連認證問題

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在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.