My Computer environment: Win7 64-bit system
1. Installation MongoDB
Go to the website to download Http://www.mongodb.org/downloads Choose the version that suits your system.
After the download good decompression, I am decompression in D disk, this even if installed well. Screenshot below:
How do I start?
Where to set up data and log storage first? Look at my screenshot above.
And then it just started.
At the command line:
D:mongodbbinmongod.exe-dbpath=d:mongodbdata
D:mongodbbinmongod.exe-logpath=d:mongodblogs
Every time this startup is troublesome, by these two lines of code into the TXT file, and then the suffix to bat, as shown above my run.bat, this is my own built.
Note: Eat to start may fail, because if you shut down the command line interface normally, MongoDB will create a. lock file under the beat and delete it. You can also optimize the bat file so that you don't have to manually delete the file later.
2, graphical management MongoDB?
I choose the tool is Rockmongodb, he is a PHP written Mongod management tools, how to use?
Need to build a Wamp Dynamic Web server, no choice is wampserver online can be received,
After installation, you need to copy the Rockmongodb to the Wamp www file directory.
Start Wamp, pay attention to the index.php under the WWW delete or change a name, the reason is not explained.
At this time found Rockmongodb or can not be used, because the need for Phpmongodb Plug-ins, wampserver default is not to take,
To download the Php_mongodb module, address: http://www.php.net/manual/en/mongo.installation.php
See your corresponding PHP version and VC version.
Download good file decompression, the inside of the Php_mongodb.dll copy to your Wamp bin inside the PHP (with version number) in the directory of EXT asked Price
Also add in php.ini file:
?
1 |
Extension=php_mongo.dll |
Restart the Wamp, and then open the Php_mongodb module in PHP in the console, if not, you download the php_mongodb.dll wrong.
You can go to GitHub to download multiple versions, but remember to copy to Ext folder is to change the file name to Php_mongodb.dll.
Then you can use Rockmongo, how to use, to Rockmongodb's official website to see, here is not introduced.
3, Java link mongodb.
Download the MongoDB Java driver First,
The link to the official website is not very right
Accurate yes this: https://github.com/mongodb/mongo-java-driver/downloads
Select a suitable version.
Add this jar file to the path of one of your eclipse projects, and you can add it to the overall picture to see the individual's wishes.
Can the test be connected.
Notice that I'm adding a test database under Rongmongdb, and then I built a blog set containing a data {name:peng,age:100}
Java Test Code:
?
1 2 3 4 5 6 7 8 9, |
import java.net.UnknownHostException; import Com.mongodb.DB; import COM.M Ongodb. Dbcollection; Import Com.mongodb.DBCursor; Import Com.mongodb.DBObject; Import com.mongodb.MongoClient; public class Demo { public static void main (string[] args) throws Unknownhostexception {&N Bsp; mongoclient client = new Mongoclient (); db DB =client.getdb ("test"); dbcollection blog=db.getcollection ("blog"); system.out.println (Blog.find ()); dbcursor Cursor=blog.find (); for (DBObject dbobject:cursor) {    &NBSp; system.out.println (DBObject); } }} |