Showing posts with label mongodb. Show all posts
Showing posts with label mongodb. Show all posts

Thursday, October 24, 2019

Uninstall Mongo old version and Install new version

1) backup data

mkdir mongodb-dump-oct24-2019
cd mongodb-dump-oct24-2019
mongodump

Above will create a folder called 'dump' within 'mongodb-dump-oct24-2019' folder.

2) Uninstall existing version of mongodb
https://medium.com/@rajanmaharjan/uninstall-mongodb-macos-completely-d2a6d6c163f9

3) Install new version
https://stackoverflow.com/questions/57856809/installing-mongodb-with-homebrew

brew tap mongodb/brew  
brew install mongodb-community@4.0
4) brew link --force mongodb-community@4.0
brew services start mongodb-community@4.0
5) Restore data
cd mongodb-dump-oct24-2019
mongorestore

Monday, September 16, 2019

Rails & Mongo - connecting to Mongodb from rails console


client= Mongo::Client.new('mongodb://username:password@serverIP:27017/databaseName?authSource=authSource db')

db = client.database

db.collections

Tuesday, October 2, 2018

Mongo - exporting and importing a single database

On Source Machine
-------------------------
mongo
> show dbs
> exit

mongodump -d abc_xyz_development

(Above command will create a dump/abc_xyz_development folder and put all the files inside it. This folder will need to be zipped and sent to whoever wants to import the database)

On Target Machine
-------------------------

Drop existing database
mongo

> show dbs

> use abc_xyz_development;
> db.dropDatabase();
> exit

Restore from Dump folder:
Command:
  mongorestore -d
E.g.
  mongorestore -d abc_xyz_development ~/abc_xyz_development

Monday, April 16, 2018

Mongodb related

1) Export
mongodump
Above command will export everything (all databases) into a folder called 'dump'

2) Import
mongorestore dump

Monday, July 4, 2016

Mongodb - getting started

1) mongo
-  to launch mongo shell

2) db.adminCommand( { listDatabases: 1 } )
- to list the databases

3) use abc
- assuming 'abc' is one of the databases listed by command 2

4) db.getCollectionNames()
- to list all the collections
- i think we have to run our queries on Collections just like we would run queries on Tables in a Sql database

5) db.users.findOne()
- assuming 'users' is a collection

Followers

Blog Archive