Ubuntu 系統下 mongodb 安裝和配置

來源:互聯網
上載者:User

標籤:

安裝 MongoDB

  sudo apt-get install mongodb

  sudo apt-get install mongodb



關閉/啟動

  sudo service mongodb stop
  sudo service mongodb start

 

設定資料庫連接密碼:

  在跟目錄建立檔案夾: data/db

  關閉現有服務。

    sudo service mongodb stop

  重新啟動服務

    $ mongod –auth

  建立串連使用者

    $ mongo

    > use admin

    switched to db admin

    > db.addUser("root","1983")

  關閉服務(直接在 mongod 啟動的命令視窗 “ctrl + C”)

  重啟服務:

    $: mongod –auth

  查看是否開始驗證:、

    $ mongo

    MongoDB shell version: 2.0.4

    connecting to: test

    > use admin

    switched to db admin

    > show collections

    Fri Mar 14 09:07:08 uncaught exception: error: {

    "$err" : "unauthorized db:admin lock type:-1 client:127.0.0.1",

    "code" : 10057

    }

  有提示 連結錯誤。

  進行使用者驗證:

    > db.auth("root","1983")

    1

  重新查看就可以查看資料集

    > show collections

    system.indexes

    system.users

 

設定用戶端串連:

  預設安裝的話只允許 127.0.0.1 的IP 串連.

  需要修改/etc/mongodb.conf 注釋下列記錄:

  開啟檔案:

    $ sudo gedit /etc/mongodb.conf

  注釋記錄:

    #bind_ip = 0.0.0.0 

Ubuntu 系統下 mongodb 安裝和配置

聯繫我們

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