on
Starting the MongoDB Crash Course
I started to watch the crash course video.
Downloaded MongoDB server files into my coursework directory.
I wanted to see if I can start the server and conntect using the CLI just by using the README and help.
I created a local data/db directory.
sudo mkdir -p ../data/db
sudo chmod -R go+w ../data/db
./mongod --dbpath "../data/db"
Server started. I opened another terminal window, and started the CLI (shell) in the bin directory:
./mongo
Got some warnings in the shell.
- Access control not enabled for the database. R/W access to data and configuration is unrestricted
- The server is bound to localhost. Remote systems will be unable to connect to this server.
Nothing to be worried about at this time.
OK - Easier to install using brew. I’m just gonna delete what I downloaded previously.
brew tap mongodb/brew
brew tap | grep mongodb
brew install mongodb-community@4.4
Starting / Stopping the Service
To run MongoDB (i.e. the mongod process) as a macOS service, issue the following:
brew services start mongodb-community@4.4
To stop a mongod running as a macOS service, use the following command as needed:
brew services stop mongodb-community@4.4
To run MongoDB (i.e. the mongod process) manually as a background process, issue the following:
mongod --config /usr/local/etc/mongod.conf --fork
To stop a mongod running as a background process, connect to the mongod from the mongo shell, and issue the shutdown command as needed.
I am gettin errors from brew saying my macOs version “mountain_lion” is not supported. I’m running the latest version .. will have to google the problem.
I am following along the video
> show dbs
admin 0.000GB
config 0.000GB
local 0.000GB
test 0.000GB
> use test
switched to db test
> show collections
products
> db.drop
db.dropAllRoles( db.dropAllUsers( db.dropDatabase( db.dropRole( db.dropUser(
> db.dropDatabase()
{ "dropped" : "test", "ok" : 1 }
> show dbs
admin 0.000GB
config 0.000GB
local 0.000GB
> use acme
switched to db acme
> db
acme
> db.createCollection('posts')
{ "ok" : 1 }
> show collections
posts
>