【MongoDB】The Access control of mongodb,mongodbaccess

來源:互聯網
上載者:User

【MongoDB】The Access control of mongodb,mongodbaccess

In this blog we mainly talk about the access control including limitation of ip, setting listen port and usage of username and password. In the official document, mongodb server start without the argument , so once the connection was created, the remote client could do everything. But in the productive environment it’s advisable to take security into consideration and to enhance the security protection. For the sake of lowing the potential risk, the above measures could be taken to deal with these problems. 
First, Binding IP address to access MongoDB. 
Mongodb could put restriction on the ip address thought argument ‘bind_ip’ when being started. For example, now we only limit ip address[192.168.55.165] to access the server.





Secondly, use the certain port 




Thirdly,  add user and password





公司準備使用mongodb資料庫,我查了很多資料都是一些對於mongodb使用上的問題,有mongodb的費用問題

mongodb 是免費的
 
幫幫忙,我剛接觸mongodb,怎使用java對mongodb資料庫進行多條件查詢,先了

package maven.demo.test;

import java.util.ArrayList;
import java.util.List;

import com.mongodb.BasicDBObject;
import com.mongodb.DB;
import com.mongodb.DBCollection;
import com.mongodb.DBObject;
import com.mongodb.Mongo;
import com.mongodb.QueryOperators;

public class MongoDB {
private static void print(String str){
System.out.println(str);
}
public static void main(String[] args) {
try {
//建立串連
Mongo m=new Mongo("127.0.0.1", 27017);
//得到資料庫
DB db=m.getDB("test");
//得到所有資料庫
//List<String> colls=m.getDatabaseNames();
//for(String str:colls){
//System.out.println(str);
//}

////得到所有的集合(表)
//for(String collection:db.getCollectionNames()){
//System.out.println(collection);
//}

//刪除一個資料庫
//m.dropDatabase("sun");

//得到sun表
DBCollection coll=db.getCollection("things");

//查看一個表的索引
//for(DBObject index:coll.getIndexInfo()){
//System.out.println(index);
//}

//DBObject myDoc=coll.findOne();
//System.out.println(myDoc);

//添加
//BasicDBObject doc=new BasicDBObject();
//doc.put("name", "sunshan");
//doc.put("sex", "男");
//doc.put("age", 22);
//coll.insert(doc);......餘下全文>>
 

聯繫我們

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