Databases Reference
In-Depth Information
Getting and Starting MongoDB
MongoDB is almost always run as a network server that clients can connect to and
perform operations on. To start the server, run the mongod executable:
$ ./mongod
./mongod --help for help and startup options
Sun Mar 28 12:31:20 Mongo DB : starting : pid = 44978 port = 27017
dbpath = /data/db/ master = 0 slave = 0 64-bit
Sun Mar 28 12:31:20 db version v1.5.0-pre-, pdfile version 4.5
Sun Mar 28 12:31:20 git version: ...
Sun Mar 28 12:31:20 sys info: ...
Sun Mar 28 12:31:20 waiting for connections on port 27017
Sun Mar 28 12:31:20 web admin interface listening on port 28017
Or if you're on Windows, run this:
$ mongod.exe
For detailed information on installing MongoDB on your system, see
Appendix A .
When run with no arguments, mongod will use the default data directory, /data/db/ (or
C:\data\db\ on Windows), and port 27017. If the data directory does not already exist
or is not writable, the server will fail to start. It is important to create the data directory
(e.g., mkdir -p /data/db/ ), and to make sure your user has permission to write to the
directory, before starting MongoDB. The server will also fail to start if the port is not
available—this is often caused by another instance of MongoDB that is already running.
The server will print some version and system information and then begin waiting for
connections. By default, MongoDB listens for socket connections on port 27017.
mongod also sets up a very basic HTTP server that listens on a port 1,000 higher than
the main port, in this case 28017. This means that you can get some administrative
information about your database by opening a web browser and going to http://local
host:28017 .
You can safely stop mongod by typing Ctrl-c in the shell that is running the server.
For more information on starting or stopping MongoDB, see “Starting
and Stopping MongoDB” on page 111 , and for more on the adminis-
trative interface, see “Using the Admin Interface” on page 115 .
 
Search WWH ::




Custom Search