Community Serverversion for your operating system
The Mac OS version called Catalina
which was released October 7, 2019 BREAKS THE ABILITY to make a directory at the top level. You
will need to install and run from your user directory, for both the mongo installation
and the data directory. Also, depending if you have full access to everything or not, you may not
even be able to do that. If you get stuck and nothing you try seems to work, get help right away
or even see if you can use someone else's computer for this part of the assignment.
In addition, these instructions DO NOT use the brew
or home brew
utility, so if
you decide to go that route for installation, you will need to find your own instructions. This
page is STRICTLY for the manual installation method.
downloads folder, but double-check where it goes so you can find it later
tar xzf mongodb-osx-x86_64-[version].tgz3.6.5so the file name would be
mongodb-osx-ssl-x86_64-3.6.5.tgztarcommand will
untarthe archived file; the
xzf
means extract from the zipped archive file named…
sudo mv mongodb-osx-x86_64-[version] /usr/local/mongodbsudo mkdir -p /data/db-pargument means make the parent directory if it's needed
sudo chown [username] /data/db[username]is the name on the account you are using
cd ~touch .bash_profilevi .bash_profile – this will open the vi editor so you can add the next
two lines to the fileexport MONGO_PATH=/usr/local/mongodbexport PATH=$PATH:$MONGO_PATH/binesckey to get the colon prompt for vi, then enter
wqto save these changes to the .bash_profile
source ./.bash_profile to make the changes take effect in this terminal
windowecho $PATHmongo -versionMongoDB shell version: [version]if all is well
downloads folder, but double-check where it goes so you can find it later
msifile that you downloaded; Windows will start the self-installation process, with which you are undoubtedly familiar…
run as administratorto make things work
mkdir C:\data\dbC:\Program Files\MongoDB\Server\[version]where [version] is the version number of mongo, which at this writing is 3.6.4
start, then click
settings; the system settings window will appear
System. then in the system settings window enter
environmentin the search box
Edit the system environment variables; a new dialog window will appear
Environment Variables; a new dialog window will appear
Path, then click on the
Edit…button; YET ANOTHER new dialog window will appear
Newto make a new entry, then type the following into the text line entry that shows up at the bottom of the list:
C:\Program Files\MongoDB\Server\3.6\bin3.6is the version number for the Mongo you installed; make sure this is the correct version for the path you are installing!
OKfor all the open dialog windows in succession to get out of them, then close the
settingswindow
pathmongo -versionMongoDB shell version: [version]if all is well
In either a terminal window [on a mac] or a cmd window [on windows], start the mongo server by using the
command
mongod
Then open a second terminal window [or another tab] or a second cmd window and start a
client by using the command
mongo
If all is well, you should see LOTS of stuff scroll by in the first window [the server] and a good bit of
stuff appear in the second window [the client] which will be followed there by the mongo prompt which is
a single angle bracket [the greater than
sign >
]. At this point, you can enter a mongo
command. The easiest one to use would be show dbs
to see the names of the databases that are part
of the shipped installation for mongo.
To exit the client, type the command exit in the client window, then close that window [it's
the same command on either mac or windows]. To stop the server, use the control+c
command, then
close that window as well.
REMEMBER than mongo is set up to be a command line interface by default. There are many tools that you
can find to add a graphical or GUI front end to it for management purposes, but you should try to get
familiar with running it from the command line. Doing so will really connect you with the way mongo
things work, so that when it comes time to do a full stack
development effort you'll understand
what you're doing.
The next thing to do is install some data into your mongo application. The following steps will help
you install a copy of the Northwind
database, which is kind of a standard demonstration thing to
show you some of the concepts. BTW, you'll need this anyhow for an upcoming homework assignment, so you
may as well bite the bullet and install it soon.
Here are the steps:
comma-separated values] which will have the data for the database.
C:\data\db. For mac, it is likely in
/data/db.
.csv
mongodcommand
mongocommand
show dbscommand and verify that the Northwind database exists
use Northwindcommand, the execut the
show collectionscommand to verify there are collections available
db.shippers.find()command to verify that there is actually data in at least one of the collections
exitcommand, then close that window or terminal tab
control+Cinterrupt command, then close that window as well