After installation, test,admin and local are the default database. As per the MongoDB tutorial, when we insert data in collection a database will be listed in show dbs command. For a specific purpose, I want to create a new database but I did not find any information about creating a new database. I executed a command like create db dbname or create database dbname. For both of the statement I got below error: SyntaxError: Unexpected identifier

Can I know what are the steps to create a database?

1 Answer 1


Just execute on shell "use dbname" When you insert the first document on any collection you will see the db with "show dbs"

  • It worked now. Really its strange and I don't know why it didn't work earlier. I already tried by use dbname but it was giving error.
    – ursitesion
    Commented Sep 4, 2014 at 12:41

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.