I am a newbie to MongoDB.
I use mongodb db.copyDatabase command for copying database to another server.
After I copy(I got the Ok sign from mongo shell), I found something strange.
In my source Server db
> show dbs
newstrust 13.947GB
In my Target Server db
> show dbs
ntrust1 2.188GB
I checked my db and compare source server db and target server db. The number of collections and rows are same.
I am not able to understand the problem
Related
I am on Linux Server. My MongoDB Database is stored there. Now if I want to delete the database from another machine lets say my development machine, then for that I created the steps but not working for me.
create a delete.sh file
#!usr/bin/env mongo
#instance Ip assume:
mongo 12.122.12.12:27017/tempDatabase --eval "db.dropDatabase"
But I am unable to delete the Database. Any idea that where I have done mistakes. Any interaction is really appreciated
Mongo server: Windows 10 (host)
client: CentOS 6.2, a virtual box vm on windows 10 host. This is actually a cloudera quick start vm.
Issue:
mongodb connects to the remote server (from CentOS to Windows) via terminal, lists the databases fine, but 'show collections' just returns blank. That said, the collections are accessible because I can query any collection and the count also gives me the correct results.
On the other hand, I have connected to the same mongo server from IntelliJ and it shows all the collections just fine.
Just curious as to why this is happening.. Any comments?
Side Note: is there a mongodb command to count the number of collections in a database?
Thanks
_Vamsi
Make sure you are using the database you want to show the collections for. You may be using a database that doesn't have any collections.
> use desiredDatabase
> show collections
If the list is still empty, try signing in with an admin user account. The user needs to be able to perform the listCollections action. The dbAdmin role includes the listCollections action.
To get the count you can use the getCollectionNames function which returns an array and you can get the length from that.
> db.getCollectionNames().length
I have setup mongodb 64bits on Windows. I ran server and client successfully.
But when I type:
show dbs
Output is
local 0.000GB
Why ? show dbs is supposed to list all databases at least the default one "test"
am I wrong ?
Although you may be in the test database by default, the database does not actually get created until you insert a document into a collection in the database which will implicitly create the collection and the database.
I am new in Meteorjs and i am using mongo db which comes with the meteor package.
I have made one small meteor application using mongodb and now i want to take backup of the mongo db database. I have seen many web sites and still i am not able to backup my data base. Everyone explained the same thing that in mongo db folder use mongodump and mongostore but when i use mongodump and mongostore on my terminal then it displays something like 'mongodump' is not an internal or external source command. Can u please help me in finding out the solution.
I have found that the easiest way to backup your database (or move it between meteor installations for that matter) is to simple copy the files in .meteor\local\db
Then you don't have to worry about all that mongodb dump stuff. Simple.
I apologize if this is easily google-able or already asked before.
I have tried googling, but I get hits to explain how to get all collections.
I am using MongoDB 2.4.8
Run show databases or show dbs in the Mongo shell:
$ mongo
MongoDB shell version: 2.4.8
connecting to: test
> show databases
db1 0.203125GB
local 0.078125GB
test 0.203125GB
This will list your databases.
To list the available databases, use the helper show dbs. See also How can I access different databases temporarily? to access a different database from the current database without switching your current database context (i.e. db..) source