mongodb 遠程訪問配置

一、首先修改mongodb的配置文件 讓其監聽全部外網ipmongodb

 

編輯文件:/etc/mongodb.confshell

修改後的內容以下:數據庫

    bind_ip = 0.0.0.0spa

    port = 27017rest

   auth=truecode

二、/etc/init.d/mongodb restartip

三、鏈接rem

#本地鏈接it

/usr/local/mongodb/bin/mongo
 
#遠程鏈接
 
/usr/local/mongodb/bin/mongo 127.0.0.1 /admin -u username -p password
四、給某個數據庫添加用戶訪問權限
  db.addUser('user','pwd')
  db.auth('user','pwd')
五、刪除用戶
db.removeUser('username')
相關文章
相關標籤/搜索