# You can easily install mongodb to run locally on your windows machine using chocolatey
# run
$ choco install mongodb
# to properly set up, add the mongodb path -- in my case it is; C:Program FilesMongoDBServer5.3in -
# to your system environment variables
# then test your installation
$ mongo --version
# expected output
# MongoDB shell version vx.y.z
# Build Info: {
# "version": "x.y.z",
# "gitVersion": "ea201bb0ab5fa4c9c9d27c29a538987db15c0a36",
# "modules": [],
# "allocator": "tcmalloc",
# "environment": {
# "distmod": "windows",
# "distarch": "x86_64",
# "target_arch": "x86_64"
# }
#}
npm i mongoose
## Short Method: Use Chocolatey (A package manager for Windows)
## After Installing Choco (https://chocolatey.org/install)
choco.exe install mongodb-shell -y
## Long Method: Download Installer
# Download Installer here: https://www.mongodb.com/try/download/shell
# Select Your OS & MongoDB version, Click Download
# Run the downloaded installer & follow the wizard through installation
## Using MongoDB Shell
# Connect to a LOCAL MongoDB Instance:
mongosh "mongodb://localhost:27017"
# Specify Database Name
mongosh "mongodb://localhost:27017/hevodb"
# Custom Port
mongosh —-port 28089
# Connect to a REMOTE MongoDB Instance
mongosh –host mongodb0.example.com –port 28015
Best platform
in <project-name>/app.js
var app = express();
/*....*/
//////mongoose
// Set up mongoose connection
var mongoose = require('mongoose');
var dev_db_url = 'mongodb+srv://<username>:<password>@cluster0.sekti.mongodb.net/example?retryWrites=true&w=majority';
var mongoDB = process.env.MONGODB_URI || dev_db_url;
const uri = process.env.MONGODB_URI;
mongoose.connect(mongoDB, {useNewUrlParser: true, useUnifiedTopology: true});
mongoose.Promise = global.Promise;
var db = mongoose.connection;
db.on('error', console.error.bind(console, 'MongoDB connection error:'));
//////
///replace <username> and <password> with your actual username and password of course
openssl rand -base64 756 > /opt/mongo-keyfile chmod 400 /opt/mongo-keyfile chown mongodb:mongodb /opt/mongo-keyfile
Code Example |
---|
Shell :: how to install windows from a hard drive |
Shell :: unzip specific folder linux |
Shell :: install serverless framework |
Shell :: cent os GUI install |
Shell :: android debug keystore windows |
Shell :: how to turn on tomcat server mac terminal |
Shell :: install yarn on ubuntu |
Shell :: nvm install |
Shell :: powershell array |
Shell :: permissão wordpress |
Shell :: Unsupported upgrade request. |
Shell :: ls order by date |
Shell :: install mongosh |
Shell :: comments in bash file |
Shell :: start xampp on mac |
Shell :: aws cli on heroku |
Shell :: git stash save untracked |
Shell :: docker auto start when reboot |
Shell :: current git id |
Shell :: npm install -g express |
Shell :: docker setup |
Shell :: view file in terminal |
Shell :: github how to remove changes |
Shell :: uncommit local commit |
Shell :: apt list available versions |
Shell :: bash replace substring in string |
Shell :: start of .sh file |
Shell :: git pull not taking latest changes |
Shell :: composer php |
Shell :: wc bash |