Active4 months ago
In the directory that you ran mongo.exe you should also see the executable mongod.exe. Mongo.exe is the shell that connects to the server/daemon that allows you to issue commands and query your databases.; mongod.exe is the actaul mongo server/daemon.; First run mongod.exe to start the server then in a new command window run mongo.exe.The shell should now connect to the running server. At the most basic level, the mongo shell command can be used to quickly connect to a specific database. In this example, we'll use it to connect to the bookstore.
I'm trying to run Mongo from the Command-Line: What's wrong? (I've IIS on localhost:80). And Apache on port 8080. Are there any issues with this?
shA.t13.5k44 gold badges4040 silver badges7777 bronze badges
markomarko5,6341414 gold badges6262 silver badges8484 bronze badges
11 Answers
Did you create the default db path?
It defaults to '
Source: http://www.mongodb.org/display/DOCS/Starting+and+Stopping+Mongo
shA.tIt defaults to '
/data/db
directory (or c:datadb
on Windows)'Source: http://www.mongodb.org/display/DOCS/Starting+and+Stopping+Mongo
13.5k44 gold badges4040 silver badges7777 bronze badges
JHNJHN
I found that when I got this error it wasn't because I didn't have my default db path set up. It was because I was trying to run mongo.exe before running mongod.exe.
Don HoganDon Hogan
- As Admin, create directory:
- As Admin, install service:
- Start MongoDB:
- Start Mongo Shell:
13.5k44 gold badges4040 silver badges7777 bronze badges
rahanrahan
Follow
- Create default db folder.c:datadband also log folderc:datalogmongo.logor use following commands in command-prompt
- Create config file in bin folder of mongo (or you may in save your desired destination).Add following in text file named 'mongod' and save it as
mongod.cfg
dbpath=c:datadb
logpath=c:datalogmongo.logor use following commands in command-prompt - Now open command-prompt (administrator) and run the following command to start mongo server
- Open another command-prompt (don't close 1st prompt) and run client command:
Hope this will help or you have done this already.
Brian Tompsett - 汤莱恩4,4771414 gold badges4040 silver badges109109 bronze badges
Sameer JadhavSameer Jadhav
The error occurs when trying to run mongo.exe WITHOUT having executed mongod.exe.The following batch script solved the problem:
MoonKnight17.2k2626 gold badges116116 silver badges216216 bronze badges
user4166159user4166159
If you are getting these type of errors when running mongod from command line or running mongodb server,
then follow these steps,
then follow these steps,
- Create db and log directories in C: drive
C:/data/db and C:data/log - Create an empty log file in log dir named mongo.log
- Run mongod from command line to run the mongodb server or create a batch file on desktop which can run the mongod.exe file from your mongodb installation direction. That way you just have to click the batch file from your desktop and mongodb will start.
- If you have 32-bit system, try using --journal with mongod command.
5,8661212 gold badges2222 silver badges3838 bronze badges
Abdul MannanAbdul Mannan
Create default db folder.
and also log folder
or use
Igorfollowing
commands in command-prompt8,90233 gold badges4141 silver badges6060 bronze badges
Vijay ChauhanVijay Chauhan
you can use below command,
where D:homemongodata is the data storage path
Amith5,22866 gold badges2424 silver badges4242 bronze badges
sambasamba
- Go to C:Program FilesMongoDBServer3.4bin using cmd andwrite mongod.
- Open another cmd by right click and run as admin point to yourmonogodb installed directory as mentioned above and then just likewrite this
mongo.exe
- After that, write
db.test.save({Field:'Hello mongodb'})
this commandwill insert a field having name Field and value is Hellomongodb. - After, check the record
db.test.find()
and press enter you will findthe record that you have recently entered.
Mohd AkramMohd Akram
For this error, if you are using windows 7 or windows server 2008 R2, the problem could be that you have to install a microsoft hotfix.
Refer to this link: https://support.microsoft.com/en-us/kb/2731284
PierreDuc36.5k55 gold badges7171 silver badges8888 bronze badges
Ritesh ChoudharyRitesh Choudhary
Steps to start a certain local MongoDB instance and to connect to in from NodeJS app:
- Create
mongod.cfg
for a new database using the pathC:Program FilesMongoDBServer4.0mongod.cfg
with the content - Install mongoDB database by running
mongod.exe --config 'C:Program FilesMongoDBServer4.0mongod.cfg' --install
- Run a particular mongoDB database
mongod.exe --config 'C:Program FilesMongoDBServer4.0mongod.cfg'
- Run mongoDB serviceand !see mongoDB actual connection string to coonect to the service from NodeJS app
4,48511 gold badge3131 silver badges3939 bronze badges
Not the answer you're looking for? Browse other questions tagged windowsmongodb or ask your own question.
- MongoDB Tutorial
- Advanced MongoDB
- MongoDB Useful Resources
- Selected Reading
In this chapter, we will see how to create a database in MongoDB.
The use Command
MongoDB use DATABASE_NAME is used to create database. The command will create a new database if it doesn't exist, otherwise it will return the existing database.
Syntax
Basic syntax of use DATABASE statement is as follows −
Example
If you want to use a database with name <mydb>, then use DATABASE statement would be as follows −
To check your currently selected database, use the command db
If you want to check your databases list, use the command show dbs.
Your created database (mydb) is not present in list. To display database, you need to insert at least one document into it.
In MongoDB default database is test. If you didn't create any database, then collections will be stored in test database.