Installation of MongoDB in window and linux
1. First go to the official website (http://www.mongodb.org/downloads) to download the appropriate installation package, the latest version is 2.6
The installation package has zip and msi format, here it is recommended to download zip format,msi is actually decompressed, and do not choose the installation path when installing, default installation to C:\Program Files\MongoDB 2.6 Standard directory, according to your system choose 32-bit or 64-bit
My own computer is win8 64-bit, download the 64-bit zip package, download it and unzip it to D:\MongoDB directory
Create the database directory D:\MongoDB\data, then open a command line window, switch to the D:\MongoDB\bin directory and execute the following command:
mongod --dbpath D:\MongoDB\data
This command line window will print some startup information, and the last line will show the following information, indicating that the startup is successful.
2014-04-23T10:38:48.391+0800 [initandlisten] waiting for connections on port 27017
This is entered in the browser http://localhost:27017/and you can see the message displayed as
It looks like you are trying to access MongoDB over HTTP on the native driver port.
Specific screenshots are as follows:
Mongodb is now installed. It's much simpler than I thought.
MongoDB as a Windows service:
Installing mongodb as a windows service is very simple just add--install to the command line executed above
mongod --dbpath D:\MongoDB\data --install
According to the normal scenario, the service should be installed successfully, but unfortunately, the following prompt appears
--install has to be used with --logpath
As prompted, we need to specify the logs directory, so we create the logs directory D:\MongoDB\logs and execute the command again.
Then put the bin of MongoDB into the environment variable (you can see http://blog.chinaunix.net/uid-25810793-id-3257898.html for adding environment variables)
With the new cmd, execute the following command:
Mongo enters the database.
show dbs;
Next time enter if input Mongo cannot be opened
mongod --dbpath D:\MongoDB\data --logpath D:\MongoDB\logs\MongoDB.log --install --serviceName MongoDB
Enter Mongo again and you can open it.
Mongodb is installed in Linux.
wget http://fastdl.mongodb.org/linux/mongodb-linux-x86_64-2.2.6.tgz
(Address:http://download.csdn.net/detail/u011575570/9055565)
1. installation preparation
Move mongodb to the/usr/local/montdb folder
mv mongodb-linux-i686-1.8.2 /usr/local/mongodb
Create database folders and log files
mkdir /usr/local/mongodb/data
touch /usr/local/mongodb/logs
2. Set boot up auto-start
appends the mongodb startup entry to rc.local to ensure that mongodb starts when the server boots
echo "/usr/local/mongodb/bin/mongod --dbpath=/usr/local/mongodb/data --logpath=/usr/local/mongodb/logs --logappend --auth -port=27017" >> /etc/rc.local
4. Start mongodb server
cd to bin folder under mongodb directory to start mongodb
/usr/local/mongodb/bin/mongod --dbpath=/usr/local/mongodb/data --logpath=/usr/local/mongodb/logs --logappend --port=27017 --fork
5. Enter database interface (start mongodb client)
cd to bin folder under mongodb directory, execute command./ mongo
Run as follows:
[root@namenode mongodb]# ./ bin/mongo
MongoDB shell version: 1.8.2
connecting to: test
>show dbs