Creating a database in Mongo: can't connect, get “connect failed”

后端 未结 5 833
刺人心
刺人心 2020-12-13 19:02

I want to create a new database in Mongo. However, I\'m having trouble connecting:

:~$ mongo
MongoDB shell version: 1.6.5
connecting to: test
Tue Dec 21 18:         


        
5条回答
  •  暖寄归人
    2020-12-13 20:00

    In order to open Mongo JavaScript shell, a Listener should be initialized first.

    So, first run mongod.exe before running mongo.exe. Both are in the same location(/bin).

    There is no separate commands to create a db in mongodb. Just type "use dbname;" in console. Now you have created a db of the name 'dbname'. Now, if you type 'show databases' you cannot see the db name you just created. Because, mongo will not create any db, util you create collection and insert a document into that collection.

    Hope this is useful to you!

提交回复
热议问题