【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);......餘下全文>>