this course appears to be quite out of date. I had issues even installing MongoDB and had to resort to these instructions mongodb - Read-only file system when attempting mkdir /data/db on Mac - Stack Overflow
I’m now in section 4. Connecting to MongoDB, of CRUD Operations Using Mongoose and it isn’t working. Any help would be appreciated. The error I’m getting is …
could not connect to mongodb MongoParseError: Invalid scheme, expected connection string to start with “mongodb://” or “mongodb+srv://”
Thank you in advance!
I spent quite a while trying to figure out how to install MongoDB and Mongoose also. My problem was one mentioned in the Stack Overflow post you linked. That with the new macOS Catalina update, the folder
/data/db is read-only, you cannot modify it, so you have to store your database files somewhere else. I had to go through the MongoDB Installation Documentation, which is summarized below.
1. To install xcode, run in your macOS Terminal:
$ xcode-select --install
2. To install
brew use the official Homebrew Installation Instructions.
3. To tap the MongoDB Homebrew Tap, run in your macOS Terminal:
$ brew tap mongodb/brew
4. To update Homebrew and all existing formulae:
$ brew update
5. To install MongoDB:
$ brew install firstname.lastname@example.org
To start MongoDB, run:
$ brew services start email@example.com
To stop MongoDB, run:
$ brew services stop firstname.lastname@example.org
To verify that MongoDB is running:
$ brew services list
To check where your database files are being stored run:
$ sudo lsof -p `ps aux | grep mongodb | head -n1 | tr -s ' ' | cut -d' ' -f 2` | grep REG
When I ran this command it showed that my files are being stored in a hidden file in my harddrive, Macintosh HD. In Finder you can push
SHFT + CMD + . to show hidden files. If this command returns file names with a folder called mongodb, then you are good to go.
If your files are still read-only, you can try to overwrite the default storage path with:
$ mongod --dbpath /System/Volumes/Data/data/db
To verify your MongoDB version:
$ mongod --version
I replied to this several days ago and a bot hid my response so I put it on this Stack Overflow post.
If you scroll down on the post my response is the one that starts with…
“I spent quite a while trying to figure out how to install MongoDB and Mongoose. My problem with the new macOS Catalina update, the folder
/data/db is read-only, you cannot modify it, so you have to store your database files somewhere else. I had to go through the MongoDB Installation Documentation, which is summarized below.”
Not sure how long until the other post gets reviewed but Stack Overflow also allowed me to include more links than I could here. Hope it helps!
Hey, maybe you guys can use mongo with docker, should be easy to do it, or more easy way just use mongo atlas, create an account, and free cluster anywhere, then mongo can provide you with a connect option which is basically the string connection to your mongo database
Thank you! This clarified so much for me.
How to follow along with Mosh and download MongoDB for a Mac as of 4/2023:
It appears the process for installing mongodb is slightly updated here: https://www.mongodb.com/docs/manual/tutorial/install-mongodb-on-os-x/
If you follow the instructions there under “Install MongoDB Community Edition” you should be set. Then, make sure to start the mongodb server with this command per the documentation under “Run MongoDB Community Edition”:
brew services start email@example.com
Then, after downloading Mongodb Compass (from here MongoDB Compass Download (GUI) | MongoDB) , you should be able to click connect in Mongodb compass and be off to the races.
(Sidenote) - It also appears there’s an easy way to find out where that Mongodb database is hiding on a mac. If you check out the link above (at the time of writing), there are paths to what’s called the “data directory.” I cd’d into that and found the directory for the database. No need for any fancy commands it seems to access it.