Database Reference
In-Depth Information
However, you don't need to do anything further to install the application. Indeed, it doesn't take much more time
to install MongoDB manually—depending on what else you need to install, it might even be faster. Manually installing
MongoDB does have some downsides, however. For example, the executables that you just extracted and found in the
bin directory can't be executed from anywhere except the bin directory by default. Thus, if you want to run the mongod
service, you will need to do so directly from the aforementioned bin directory. This downside highlights one of the
benefits of installing MongoDB through repositories.
Installing MongoDB under Windows
Microsoft's Windows is also a popular choice for server software, including Internet-based services.
Windows doesn't come with a repository application like apt-get, so you'll need to download and extract the
software from the MongoDB website to run it. Yes, the preceding information is correct. You do not need to walk
through any setup process; installing the software is a simple matter of downloading the package, extracting it, and
running the application itself.
For example, assume you've decided to download the latest stable version of MongoDB for your 64-bits
Windows 2008 server. You begin by extracting the package ( mongodb-win32-x86_64-x.y.x.zip ) to the root of your
C:\ drive. At this point, all you need to do is open a command prompt (Start Run cmd OK) and browse to the
directory you extracted the contents to:
> cd C:\mongodb-win32-x86_64-x.y.z\
> cd bin\
Doing this brings you to the directory that contains the MongoDB executables. That's all there is to it: as I noted
previously, no installation is necessary.
Running MongoDB
At long last, you're ready to get your hands dirty. You've learned where to get the MongoDB version that best suits
your needs and hardware, and you've also seen how to install the software. Now it's finally time to look at running and
using MongoDB.
Prerequisites
Before you can start the MongoDB service, you need to create a data directory for MongoDB to store its files in.
By default, MongoDB stores the data in the /data/db directory on Unix-based systems (such as Linux and OS X)
and in the C:\data\db directory on Windows.
MongoDB does not create these data directories for you, so you need to create them manually; otherwise,
MongoDB will fail to run and throw an error message. Also, be sure that you set the permissions correctly: MongoDB must
have read, write, and directory creation permissions to function properly.
Note
If you wish to use a directory other than /data/db or C:\data\db , then you can tell MongoDB to look at the
desired directory by using the --dbpath flag when executing the service.
Once you create the required directory and assign the appropriate permissions, you can start the MongoDB core
database service by executing the mongod application. You can do this from the command prompt or the shell in
Windows and Linux, respectively.
 
 
Search WWH ::




Custom Search