I have an existing database for a discord bot in MongoDB Compass v1.28.1 I want to transfer all the data in the database to mongodb atlas because of its more extensive functionality and to not have to wait for compass to take ages to load each time I open it. However when I follow the steps to connect that are provided in Atlas, the pop-up that's supposed to appear when I copy a path to the clipboard doesn't appear, and nothing happens. I tried to connect through my app in VSCode, the same way I did for Compass, using mongoose. Still no collections are loading or any data being stored. I have made my schemas etc. which work perfectly fine in Compass...
Migration to Atlas is documented at https://docs.atlas.mongodb.com/import/
To save you some reads, you have to options - export/import and mongodump/mongorestore.
I would recommend to try export/import first. It's built into Compass https://docs.mongodb.com/compass/current/import-export/ and must be simpler to use considering limited experience with mongo. It's UI oriented so just follow the click-through guide in the documentation.
Unfortunately it has some limitations related to data type conversion from BSON to JSON and may be a bit tedious if you have large number of collections.
In this case you will need to follow CLI mongodump/mongorestore way #barrypicker suggested in the comments. Both commands are available in cmd and PowerShell consoles.
First you backup your local database https://docs.mongodb.com/v4.2/reference/program/mongodump/:
mongodump --uri="mongodb://username:password#localhost:27017/discordbot"
username and password are the ones you use in compass to connect to the source database.
It will create dump directory with all collections you have.
Then you have to upload the backup to Atlas:
mongorestore --uri="mongodb+srv://username:password#cluster.tenant.mongodb.net/database" dump/
username and password are the ones you use to connect to atlas cluster, listed in the "Security/Database Access" section.
You can get the exact subdomains for the --uri part from Atlas. In the dashboard click "Connect" button for the cluster you want to connect to, then choose "shell" as the connection method in the connection pop-up:
Related
I ran mongod in Hyper Terminal.
I established connection with Studio3T and MongoDB. And created collection and documents in Studio3T. The database, collection, and documents appear in Studio3T and MongoDB. In Hyper the database and collection exist, but the documents are not there. Any idea why?
I have consulted stackoverflow and could not find the answer in the resources listed (sorry if I missed something):
Mongoose always returning an empty array NodeJS
Model.find() returns empty in mongoose
Mongoose always return empty array?
What are naming conventions for MongoDB?
MongoDB:
Mongosh in Hyper:
Studio3T:
Code in Atom:
Run code and result in Hyper:
I started mongod and connected to the MongoDB server locally. My application code pointed to the following:
mongoose.connect("mongodb://localhost:27017/wikiDB");
The above is local. But my data is on the cloud-based MongoDB Atlas Cluster. I shouldn't need to run mongod. So, I changed my application code:
mongoose.connect("mongodb+srv://admin-yourname:password#blahblahblah.mongodb.net/wikiDB");
where yourname AND password AND blahblahblah are specific to the coder.
Now my application code points to the Atlas Cluster where my data is.
Summary:
My data is on the cloud-based Atlas Cluster.
To see my data on the Atlas Cluster from the command line, I "Connect with the MongoDB Shell" and run the connection string that MongoDB provides in the command line. Now I see my data in the command line.
To see my data on the Atlas Cluster when I run my code, I use "Connect your application" and place the connection string that MongoDB provides in my code (the mongoose.connect(....) ). Now when I run my code, I can see my data in my browser or command line if I console.log it.
If you are in the command line and run mongod in one tab, and mongosh in another, and use db.articles.find(), then nothing will appear but an empty array. That's because the data is on the cloud-based Atlas cluster. In this instance, you are viewing things locally.
If your application code points to your local MongoDB server (ran mongod in one tab, mongosh in another), then when you run the code you will see nothing but an empty array because the data is on the cloud-based Atlas cluster. In this instance, you are viewing things locally.
I'm new to MongoDB and I'm having some problems with MongoDB recently.
I'm not sure about Connect with the MongoDB Shell, Connect your application, Connect using MongoDB Compass, what's the difference?
The current demand is. I want to directly allow connection from anywhere and create a user account password to log into this database, which option should I choose?
https://i.stack.imgur.com/iwYMf.png
In Connect your application tab, you get a link that you need to copy
and paste in your application you are building to connect it to the
database. Remember to replace your password and databse name.
In Connect using MongoDB Compass tab, you get a link that you need
to paste in your compass application(A desktop application that
makes your mongodb data handling so much easier). And again remember to replace
your credentials.
I'm not very fond of Mongodb shell. It's actually an extensible
command-line interface.
I can connect to a MongoDB Atlas replica set but it has no database.
When I click the master node, it shows a new shell
And I can find the objects with db.getCollection('aCollection').find()
How can I show/add the database in the left pane?
ps. I was using Robo3T 1.3.1
IMO this is a issue of insufficient privileges on the user account used to log in to ROBO3T and access MongoDB. You can follow this link. It points to a similar issue on Robo3Ts Github. You can use MongoDB Compass to connect to remote/Atlas MongoDB instances too. It is much user friendly.
This worked for me. Just set MongoDB Roles to atlasAdmin#admin.
I install the mongodb and the Robomongo to control it. but when I use the shell to create table and insert something into it,I can see it in the shell but in the Robomongo I cannt see it,and the database list show the used space is 0.000GB,here is the picture
I have checked the permission of it own files include the config file and the storage file, it's all 777, the version of the mongodb is 3.2.6.
Are you able to connect to your database server using roboMongo?
If yes, then in the roboMongo explorer window,
Expand the database you wish to see.
expand collections folder. You must be able to see your collection.
Right click on the collection and choose "View Documents"
And if you are not able to connect to the database server, check the connection Address, portNumber, Authentication details etc.
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.