Failed to create mongodb db

According to this documentation , use mays should create a db if it has not already been created:

Using MongoDB DATABASE_NAME is used to create the database. The team will create a new database if it does not exist, otherwise it will return the existing database.

So why does mongo use mays not work?

 root@server88-208-249-95 :~# mongo use mays MongoDB shell version: 2.6.11 connecting to: use 2015-09-16T22:17:20.316+0100 file [mays] doesn't exist failed to load: mays 
+5
source share
3 answers

The use command does not work with the mongo command. You need to open the mongo shell and then use the "use" command.

Open a terminal -> type 'mongo' to get the mongo shell -> use db_name

This will create the database if it no longer exists.

The database is not displayed when using 'show dbs' until you create a collection in it.

Use db.createCollection ("collection_name") and then use 'show dbs' and you will see your newly created database.

+6
source

You need to create at least one collection before it saves the database. Issuing a use will create it, but will not automatically save it. You can create an empty collection using db.createCollection ("test"). To verify, run the following commands from the mongo shell:

 use mays show dbs (mays will not show up) db.createCollection("test") show dbs (mays will show up) 
+2
source

Please someone can help me. I generally could not create a database for MongoDB, here is my last attempt? Any help would be awesome since I really need this to work.

I tried and tried to add my code here, but it does not accept any code that I add here in any way, even when I use ctrl k, so I can not show you my code.

I tried mkdir --p / data / db and got permission denied. I tried >> sudo chown -R $ USER / data / db and did not get such a file or directory.

Could someone, PLEASE tell me how I can create a database for mongodb, since I tried everything that I can find so far to no avail.

thanks

0
source

All Articles