- 在C盘下创建db目录用于存放数据
c:\>cd c:\
c:\>mkdir data
c:\>cd data
c:\data>mkdir db
- 在C:\mongodb\bin\目录下运行如下命令以把db目录设为数据仓库
./mongod --dbpath c:\data\db
- 启动 MongoDB 服务器
./mongod
应该会看到如下场景
2017-11-25T15:25:55.909+0800 I CONTROL [initandlisten] MongoDB starting : pid=11100 port=27017 dbpath=C:\data\db\ 64-bit host=DESKTOP-6SVSFQS
2017-11-25T15:25:55.910+0800 I CONTROL [initandlisten] targetMinOS: Windows 7/Windows Server 2008 R2
......
2017-11-25T15:25:56.763+0800 I NETWORK [thread1] waiting for connections on port 27017
- 另开一个git bash窗口,在C:\mongodb\bin\目录下运行如下命令以进入 MongoDB shell
./mongo
应该会看到如下场景
MongoDB shell version v3.4.10-36-g1055daf
connecting to: mongodb://127.0.0.1:27017
MongoDB server version: 3.4.10-36-g1055daf