When I create a meteor app, where is the database?
I have an app called leaderboard, but when I run mongo shell and do show dbs I see only local (empty) and test but test doesn't doesn't have the same contents as my leaderboard app. Where does meteor create the Mongo database and how can I access it from mongo shell (so I can load some data into it)?
You need to be running the application with the meteor run command in one session, at which point you can run mongo meteor in another session on the same machine, which will include something like
[kfullert#shotgun ]$ meteor mongo
MongoDB shell version: 2.2.1
connecting to: 127.0.0.1:3002/meteor
At that point, you can use the URL in the "connecting to" line with the standard mongo tools (caveat - you need to be running your project with meteor at the same time, as "meteor run" is what spins up the mongo server for your project
[kfullert#shotgun ]$ mongo 127.0.0.1:3002/meteor
MongoDB shell version: 2.2.3
connecting to: 127.0.0.1:3002/meteor
>
For mongoimport, you'll probably want something like:
[kfullert#shotgun ]$ mongoimport -h 127.0.0.1 --port 3002 -d meteor
Additionally, it may be possible to run mongoimport without meteor running, by using the following switch from your project root directory (untested so beware)
mongoimport --dbpath .meteor/local/db -d meteor
For apps running a local db server, APPDIR/.meteor/local/db
You can connect to your app's mongodb with meteor mongo and then us show collections to list the Meteor.Collections you've created.
Related
I have just set up a meteor localhost app, and when trying to execute "meteor mongo" on the linux terminal, it shows this error:
mongo: Meteor isn't running a local MongoDB server.
This command only works while Meteor is running your application locally. Start
your application first. (This error will also occur if you asked Meteor to use
a different MongoDB server with $MONGO_URL when you ran your application.)
If you're trying to connect to the database of an app you deployed with
'meteor deploy', specify your site's name with this command.
What sould I do??
you need to have mongo server running to run meteor mongo and access it.
first open a terminal window and run your meteor app
meteor run
then open another window and access your mongo db
meteor mongo
Ok guys I receive a bunch of files of a mongodb (.bson and .json) I want to replace my current meteor mongodb, I have read al this post about it:
meteor: how can I backup my mongo database
Mongorestore, from meteor production server to local
Restore a mongodb in meteor production server
MongoDB: mongorestore: command not found (this actually have nothing to do with my problem)
and I end writing in my terminal while meteor app was running
mongorestore -h 127.0.0.1:3001 --port 3001 -d meteor ~/Github/mongo/mongoDBRESTORE/admin/
but the problem its that terminal output is not command found
does anybody know what Im doing wrong, what its the right way to do this?
As #rgoomar pointed in the comments I need to download https://www.mongodb.org/downloads the mongodb bin files then I simple execute ~/mongodb/bin/mongorestore -h 127.0.0.1:3001 -db meteor ~/Github/mongo/mongoDBRESTORE/admin
and worked!
I am running meteor release blaze-rc1. The meteor server is running normally and I open up a new terminal tab in the same project directory and type:
$ meteor mongo
and I get
mongo: Meteor isn't running.
This command only works while Meteor is running your application
locally. Start your application first.
I have also tried
$ meteor --release blaze-rc1 mongo
and I get the same error message. What do I need to do in order to connect to meteor mongo?
I figured it out
I had to use the command
$ sudo meteor mongo
since I have to start my server using
$ sudo mrt
I guess sudo is necessary for me when using meteor. I noticed this happened after I upgraded.
This post is about backing up your meteor database
I am trying to back up my meteor database and I understand what this post is telling me to do, but I must not be in the right directory when I run the mongodump command, b/c I keep getting 'Command not found'. Or do I need to export a path?
[EDIT]
OK, now I have the binaries installed but when I run 'mongodump', I get:
couldn't connect to [127.0.0.1] couldn't connect to server 127.0.0.1:27017
... and when I run 'mongodump --host localhost:3002', I get:
couldn't connect to [localhost:3002] couldn't connect to server localhost:3002
Now what?
OK, thanks to #David Weldon, I can provide a fairly complete answer to this issue:
Backing up and restoring your local MongoDB for Meteor users (OSX)
Backup:
1) Your app must be running, so start up your Meteor server.
2) In a terminal window (NOT in the meteor mongo shell), enter: mongodump -h 127.0.0.1 --port 3001 -d meteor
This will create a 'dump' directory inside your home folder (your name under Users).
3) If you get a 'command not found' message, you probably just installed Mongo as a part of Meteor, meaning you don't have the mongo command line tools. Use a package like Homebrew to reinstall Mongo and you will have the command line tools. This will also add the correct PATH information to your system, so that it can find the tools.
Restoring:
1) From MiniMongo shell (run ‘meteor mongo’ inside your Meteor project dir), enter:
db.[collectionName].drop(); //repeat for all collections you wish to restore
2) Then, from a terminal window, enter:
mongorestore -h 127.0.0.1 --port 3001 -d meteor dump/meteor
Caveats:
The individual documents will not necessarily be in the same order after they are restored. So you need some way to sort documents that need to be presented in a certain order.
Caveats:
The individual documents will not necessarily be in the same order after they are restored. So you need some way to sort documents that need to be presented in a certain order.
There is a flag for this
mongorestore --maintainInsertionOrder
If you are restoring to a mup'ed meteor app, the command would be:
mongorestore -h 127.0.0.1 --port 3001 -d dump/meteor
If you forgot the name of your app, you can see it by going into the mongo shell and listing all databases.
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:16:25 Error: couldn't connect to server 127.0.0.1 (anon):1154
exception: connect failed
How can I connect to mongo in order to create a new database? Alternatively, can I create a new database from the command line?
Slightly surprisingly, the Mongo docs don't seem to cover how to create a database.
Thanks.
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!
cd /var/lib/mongodb/
remove mongod.lock file from this folder
sudo start mongodb (in console)
mongo (in console)
And it runs fine.
First you'll need to run mongod on one terminal. Then fire up another terminal and type mongo. This shall open the mongo shell. You also need to create /data/db/ where mongo will store your databases.
You'll need to run mongod (the daemon) before you can use mongo (the client), it's easiest to just run it in another shell; These should be in your path if mongo is installed correctly. After that the docs should get you through creating and editing dbs and collections.
Just try following commands in given order :
sudo rm /var/lib/mongodb/mongod.lock
sudo mongod --repair
sudo service mongodb start
sudo service mongodb status