mac安裝mongodb

來源:互聯網
上載者:User

標籤:

一,安裝方法1 ,下載mongodb

1,官網下載mongodb程式 https://www.mongodb.org/downloads#production?

2,解壓後啟動mongodb服務

下載放在 /User/username/app/mongoDB下

tar -zxvf mongodb-osx-x86_64-3.0.7.tgz

建立資料檔案存放目錄 進入?/User/name/app/mongoDB/mongodb-osx-x86_64-3.0.7

mkdir ?data

cd data/

mkdir db?

進入?/User/name/app/mongoDB/mongodb-osx-x86_64-3.0.7/bin

啟動mongodb服務並配置mongodb檔案存放目錄

./mongod --dbpath /User/username/app/mongoDB/mongodb-osx-x86_64-3.0.7/data/db/?

注意會有資訊列印,不要關閉視窗

?

3,啟動新視窗,啟動mongodb用戶端視窗,使用mongodb

啟動新視窗 command+N

進進入?/User/name/app/mongoDB/mongodb-osx-x86_64-3.0.7/bin

執行 ./mongo    命令

進入?MongoDB shell 命令狀態

現在可以寫mongodb shell 了。

 

4,警告解決辦法代完善...

?二,安裝方法2,brew 安裝

1,先安裝brew

2,參考mongodb官網安裝方法?,推薦使用方法1安裝。

 

 

三,使用者與角色

 

1,建立使用者
> use adminswitched to db admin> db.createUser({user:"root",pwd:"username",roles:[{role:"userAdminAnyDatabase", db: "admin" }]})Successfully added user: {"user" : "root","roles" : [{"role" : "userAdminAnyDatabase","db" : "admin"}]}?
2,重啟服務./mongod --auth  --dbpath /Users/username/app/mongoDB/mongodb-osx-x86_64-3.0.7/data/db/??3 ,使用db.auth("root","username")?> show dbs2015-11-03T17:43:10.813+0800 E QUERY    Error: listDatabases failed:{"ok" : 0,"errmsg" : "not authorized on admin to execute command { listDatabases: 1.0 }","code" : 13}    at Error ()    at Mongo.getDBs (src/mongo/shell/mongo.js:47:15)    at shellHelper.show (src/mongo/shell/utils.js:630:33)    at shellHelper (src/mongo/shell/utils.js:524:36)    at (shellhelp2):1:1 at src/mongo/shell/mongo.js:47> db.auth("root","username")Error: 18 Authentication failed.0> db.auth("root","username")Error: 18 Authentication failed.0> use adminswitched to db admin> db.auth("root","username");1> show dbs;admin  0.078GBlocal  0.078GBtest   0.078GB> 

四,遠端連線

mongo 遠程主機ip或DNS:MongoDB連接埠號碼/資料庫名 -u user -p password?

五,視覺化檢視

Robomongo

mac版本: http://mac.softpedia.com/get/Developer-Tools/Robomongo.shtml?

下載好後,輸入串連參數,mongodb預設連接埠號碼是27017。mongodb預設沒有許可權限制的,如果有在Authentication裡面配置就好。?

 

mac版 mongodb視覺化檢視robomongo

 

視覺化檢視貌似不支援mongodb3.0版本,我串連本地認證報錯,問題解決連結未試,暫時未解決(待嘗試),不過非認證模式和遠程連結均沒問題。

?

?六,問題解決

1,使用者權限問題

正宗解決方案:ibruce.info/2015/03/03/mongodb3-auth/

使用者權限問題(另一種解決方式)

21jhf.iteye.com/blog/2216103?

2,啟動服務警示告

http://www.bkjia.com/sjkqy/997187.html?

3,mongodb 常用命令

http://www.cnblogs.com/xusir/archive/2012/12/24/2830957.html?

mac安裝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.