Database Reference
In-Depth Information
Figure 2-1. The MongoDB shell
If you start the MongoDB service with the default parameters, and start the shell with the default settings, you
will be connected to the default test database running on your local host. This database is created automatically the
moment you connect to it. This is one of MongoDB's most powerful features: if you attempt to connect to a database
that does not exist, MongoDB will automatically create it for you. This can be either good or bad, depending on how
well you handle your keyboard.
Tip
There's an on-line demo shell available on the MongoDB website where you can try out any of the commands listed.
Before taking any further steps, such as implementing any additional drivers that will enable you to work with
your favorite programming language, you might find it helpful to take a quick peek at some of the more useful
commands available in the MongoDB shell (see Table 2-2 ).
Table 2-2. Basic Commands within the MongoDB Shell
Command
Function
show dbs
Shows the names of the available databases.
show collections
Shows the collections in the current database.
show users
Shows the users in the current database.
use <db name>
Sets the current database to <db name> .
Tip
You can get a full list of commands by typing the help command in the MongoDB shell.
Installing Additional Drivers
You might think that you are ready to take on the world now that you have set up MongoDB and know how to use
its shell. That's partially true; however, you probably want to use your preferred programming language rather than
the shell when querying or otherwise manipulating the MongoDB database. 10gen offers multiple official drivers,
and many more are offered in the community that let you do precisely that. For example, drivers for the following
programming languages can be found on the MongoDB website:
C
C++
C#
 
 
Search WWH ::




Custom Search