- MongoDB Administrator’s Guide
- Cyrus Dasadia
- 261字
- 2021-07-02 15:47:41
How to do it...
- In this recipe, we will be installing MongoDB in the user's home directory. Create a directory ~/data/ and extract the TAR file in this directory:
tar xvf mongodb-osx-x86_64-3.4.4.tgz
All of MongoDB's core binaries are available in the ~/data/mongodb-osx-x86_64-3.4.4/bin directory.
- Create a symbolic link to the versioned file directory for simpler naming conventions and also allowing us to use a generic directory name (for example, in scripts):
cd ~/data/
ln -s mongodb-osx-x86_64-3.4.4 mongodb
- Create a directory for the database:
mkdir ~/data/db
- Start the MongoDB server:
~/data/mongodb/bin/mongod --dbpath ~/data/db
- You should see output like this:
2017-05-21T15:21:20.662+0530 I CONTROL [initandlisten] MongoDB starting : pid=960 port=27017 dbpath=/Users/cyrus.dasadia/data/db 64-bit host=foo
2017-05-21T15:21:20.662+0530 I CONTROL [initandlisten] db version v3.4.4
2017-05-21T15:21:20.662+0530 I CONTROL [initandlisten] git version: 888390515874a9debd1b6c5d36559ca86b44babd
2017-05-21T15:21:20.662+0530 I CONTROL [initandlisten] allocator: system
2017-05-21T15:21:20.662+0530 I CONTROL [initandlisten] modules: none
2017-05-21T15:21:20.662+0530 I CONTROL [initandlisten] build environment:
2017-05-21T15:21:20.662+0530 I CONTROL [initandlisten] distarch: x86_64
2017-05-21T15:21:20.662+0530 I CONTROL [initandlisten] target_arch: x86_64
2017-05-21T15:21:20.662+0530 I CONTROL [initandlisten] options: { storage: { dbPath: "/Users/cyrus.dasadia/data/db" } }
<<--- snip -- >>
2017-05-21T15:21:21.492+0530 I NETWORK [thread1] waiting for connections on port 27017
- You can press Ctrl + C to stop the server.
- Additionally, for convenience, we can edit the system's PATH variable to include the MongoDB binaries directory. This allows us invoke the MongoDB binaries without having to type the entire path. For example, to execute the mongo client, instead of having to type ~/mongodb/bin/mongo every time we can simply type mongo. This can be done by appending your ~/.bashrc or ~/.zshrc files for bash and zsh respectively, with the following lines:
PATH=~/data/mongodb/bin:${PATH}
export PATH
推薦閱讀
- Java逍遙游記
- VMware View Security Essentials
- Spring Boot開(kāi)發(fā)與測(cè)試實(shí)戰(zhàn)
- SoapUI Cookbook
- Photoshop智能手機(jī)APP UI設(shè)計(jì)之道
- PHP+MySQL網(wǎng)站開(kāi)發(fā)技術(shù)項(xiàng)目式教程(第2版)
- 軟件測(cè)試項(xiàng)目實(shí)戰(zhàn)之性能測(cè)試篇
- 青少年美育趣味課堂:XMind思維導(dǎo)圖制作
- VMware虛擬化技術(shù)
- Swift細(xì)致入門(mén)與最佳實(shí)踐
- Windows內(nèi)核編程
- LabVIEW虛擬儀器入門(mén)與測(cè)控應(yīng)用100例
- Java Web應(yīng)用開(kāi)發(fā)給力起飛
- Practical Predictive Analytics
- 創(chuàng)新工場(chǎng)講AI課:從知識(shí)到實(shí)踐