How to install mongoDB on windows?

前端 未结 15 486
清歌不尽
清歌不尽 2020-11-29 14:55

I am trying to test out mongoDB and see if it is anything for me. I downloaded the 32bit windows version, but have no idea on how to continue from now on.

I normally

相关标签:
15条回答
  • 2020-11-29 15:30
    1. Download .msi from https://www.mongodb.com/download-center#community

    2. Double click install - complete option

    3. Installation folder C:\Program Files\MongoDB\Server\3.6\bin

    4. Create database folder in C:// - c:/data/db and c:/data/log and c:/data/log/mongo.log and set write permission if not

    5. Open cmd prompt in Administrator mode , navigate to C:\Program Files\MongoDB\Server\3.6\bin

    6. Type the following

      C:\Program Files\MongoDB\Server\3.6\bin>mongod --dbpath="c:/data/db" --logpath="c:/data/log/mongo.log"

    7. Check folder c:/data/db - there should be many files and folder

    8. Create a config file named "mongo.config" ** inside C:\data\

    9. Type the following to set the config values from newly created config file

      C:\Program Files\MongoDB\Server\3.6\bin>mongod --config C:\data\mongo.config

    10. Open another new cmd prompt in Administrator mode , navigate to C:\Program Files\MongoDB\Server\3.6\bin execute the following lines on the console.

    11. Type the following to create service for MongoDB

      C:\Program Files\MongoDB\Server\3.6\bin>mongod --install --config C:\data\mongo.config --logpath="c:/data/log/mongo.log"

      If old MongoDB service exists then need to delete the old service first before mongod --install command, run the following in a new console to delete old mongodb service

      SC STOP MongoDB

      >> SC DELETE MongoDB
      
    12. Type the following to start MongoDB

      C:\Program Files\MongoDB\Server\3.6\bin>net start MongoDB

    13. Type the following to stop MongoDB

      C:\Program Files\MongoDB\Server\3.6\bin>net stop MongoDB

    Now connect the DB on ip - 127.0.0.1 or 192.168.5.64 on port 27017 .

    ** File name - "mongo.config" , paste the following on config file -

    bind_ip = 127.0.0.1,192.168.5.64

    port = 27017

    dbpath=C:\data\db

    logpath=C:\data\log\mongo.log

    0 讨论(0)
  • 2020-11-29 15:30
    1. Download from http://www.mongodb.org/downloads
    2. Install .msi file in folder C:\mongodb
    3. Create data, data\db, log directories and mongo.config file under C:\mongodb.
    4. Add the following lines in "mongo.config" file dbpath=C:\mongodb\data\db\ logpath=C:\mongodb\log\mongo.log
    5. Start server : mongod.exe --config="C:\mongodb\mongo.config"

    That's it !!!

    0 讨论(0)
  • 2020-11-29 15:31

    I realize you've already accepted an answer for this, but I wrote this short howto article to install mongodb into the c:\wamp directory and run it as a service. Here is the gist of it.

    Create these directories

    mkdir c:\wamp\bin\mongodb\mongodb-win32...2.x.x\data
    mkdir c:\wamp\bin\mongodb\mongodb-win32...2.x.x\data\db
    mkdir c:\wamp\bin\mongodb\mongodb-win32...2.x.x\logs
    mkdir c:\wamp\bin\mongodb\mongodb-win32...2.x.x\conf
    

    Download and extract win32 binaries into c:\wamp directory along side mysql, apache.

    mongodb download page

    Create a mongo.conf file

    c:\wamp\bin\mongodb\mongodb-win32…2.x.x\conf\mongodb.conf
    
    # mongodb.conf
    
    # data lives here
    dbpath=C:\wamp\bin\mongodb\mongodb-win32...2.x.x\data\db
    
    # where to log
    logpath=C:\wamp\bin\mongodb\mongodb-win32...2.x.x\logs\mongodb.log
    logappend=true
    
    # only run on localhost for development
    bind_ip = 127.0.0.1                                                             
    
    port = 27017
    rest = true
    

    Install as a service

    mongod.exe --install --config c:\wamp\bin\mongodb\mongodb-win32...2.x.x\conf\mongodb.conf --logpath c:\wamp\bin\mongodb\mongodb-win32...2.x.x\logs\mongodb.log
    

    Set service to automatic and start it using services.msc

    Add path to mongo.exe to your path

    Need more details? Read the full article here...

    Installing MongoDB on Windows the WAMP way

    0 讨论(0)
  • 2020-11-29 15:33

    Its very simple to install Mongo DB on windows 7 ( i used 32 bit win7 OS)

    1. Install the correct version of Mongodb ( according to ur bit 32/64 .. imp :- 64 bit is not compatible with 32 bit and vice versa)

    2.u can install Mongodb from thius website ( acc to ur OS) http://www.mongodb.org/downloads?_ga=1.79549524.1754732149.1410784175

    1. DOWNLOAD THE .MSI OR zip file .. and install with proper privellages

    4.copy the mongodb folder from c:programfiles to d: [optional]

    5.After installation open command prompt ( as administrator .. right click on cmd and u will find the option)

    1. navigate to D:\MongoDB 2.6 Standard\bin

    2. run mongo.exe ... you might get this error you might get this error

    3. If you get then no isse you just need to do following steps

    i) try the coomand in following image yo will get to know the error enter image description here

    ii)This means that u neeed to create a directory \data\db

    iii) now you have two options either create above directory in c drive or create any "xyz" name directory somewhere else ( doesnot make and diffrence) .. lets create a directory of mongodata in d:

    enter image description here

    1. Now lets rerun the command but now like this :- mongod --dbpath d:\mongodata [shown in fig] this time you will not get and error

    enter image description here

    1. Hope everything is fine till this point .. open new command propmt [sufficent privellages (admin)]

    colured in orange will be the command u need to run .. it will open the new command propmt which we known as mongo shell (or mongodb shell)

    enter image description here

    11.dont close the shell[any of command promt as well] as in this we will create /delete/insert our databse operations

    1. Lets perform basic operation

    a) show databases b) show current databse c) creation of collection / inserting data into it (name will be test) d) show data of collection

    12.please find scrren shot of results of our operation .. please not :- dont close any command propmt

    enter image description here

    1. a diffrent structure type of number is object id :- which is created automatically

    2. Hope you get some important info for installing mongodb DB.

    0 讨论(0)
  • 2020-11-29 15:35

    It's not like WAMP. You need to start mongoDB database with a command after directory has been created C:/database_mongo

    mongod --dbpath=C:/database_mongo/

    you can then connect to mongodb using commands.

    0 讨论(0)
  • 2020-11-29 15:35

    1. Download MongoDB

    2. Install MongoDB

    3. Create the required folders:

    "C:\MongoDB_2_6_Standard\bin\data\db"
    "C:\MongoDB_2_6_Standard\logs"
    "C:\MongoDB_2_6_Standard\etc"
    

    NOTE: If the directories do not exist, mongod.exe will not start.

    4. Create a simple configuration file:

    systemLog:
        destination: file
        path: C:\MongoDB_2_6_Standard\logs\mongo.log
        logAppend: true
    net:
        bindIp: 127.0.0.1
        port: 27017
    

    More info about how to create a configuration file: http://docs.mongodb.org/manual/reference/configuration-options/

    5. Install MongoDB as a Windows Service (this way it will start automatically when you reboot your computer)

    Run cmd with administrator privilegies, and enter the following commands:

    "C:\MongoDB_2_6_Standard\bin\mongod.exe" --config "C:\MongoDB_2_6_Standard\etc\mongodb.conf" --dbpath c:\MongoDB_2_6_Standard\bin\data\db --directoryperdb --install
    

    6. Start the MongoDB Windows Service

    net start MongoDB
    

    7. Connect to MongoDB via shell/cmd for testing

    C:\MongoDB_2_6_Standard\bin\mongo.exe
    

    NOTE: http://docs.mongodb.org/manual/tutorial/getting-started-with-the-mongo-shell/

    8. That's it! You are done. :)

    9. Uninstall/remove the MongoDB Windows Service (if you messed up something)

    "C:\MongoDB_2_6_Standard\bin\mongod.exe" --remove
    
    0 讨论(0)
提交回复
热议问题