官網(wǎng)下載地址:https://www.mongodb.com/download-center/community
下載完后可以直接用xshell登錄kali,用rz命令傳輸?shù)椒?wù)器上或者直接下載到kali里面。
tar zxf mongodb-linux-x86_64-debian10-4.2.2
mkdir /usr/local/mongodb
cd mongodb-linux-x86_64-debian10-4.2.2/
mv * /usr/local/mongodb/
cd /usr/local/mongodb/
mkdir data
cd data/
mkdir db logs
創(chuàng)建配置文件
cd /usr/local/mongodb/bin
vim mongodb.conf
dbpath=/usr/local/mongodb/data/db #數(shù)據(jù)文件存放目錄
logpath=/usr/local/mongodb/data/logs/mongodb.log #日志文件存放目錄
port=27017 #數(shù)據(jù)庫(kù)端口
fork=true #以守護(hù)方式運(yùn)行,在后天運(yùn)行
#auth=true #需要認(rèn)證。如果放開(kāi)注釋?zhuān)捅仨殑?chuàng)建MongoDB的賬號(hào),使用賬號(hào)與密碼才可遠(yuǎn)程訪問(wèn),第一次安裝建議注釋
bind_ip=0.0.0.0 #允許遠(yuǎn)程訪問(wèn),或者直接注釋?zhuān)?27.0.0.1只允許本地訪問(wèn)
開(kāi)啟服務(wù)
root@kali:/usr/local/mongodb/bin# ./mongod -f mongodb.conf
about to fork child process, waiting until server is ready for connections.
forked process: 3607
child process started successfully, parent exiting
mongodb的使用
root@kali:/usr/local/mongodb/bin# mongo
關(guān)閉服務(wù)
root@kali:/usr/local/mongodb/bin# mongod -f mongodb.conf --shutdown
2020-01-03T11:40:22.516+0800 I CONTROL [main] log file "/usr/local/mongodb/data/logs/mongodb.log" exists; moved to "/usr/local/mongodb/data/logs/mongodb.log.2020-01-03T03-40-22".
killing process with pid: 3607
配置到系統(tǒng)環(huán)境變量
vi /etc/profile
export PATH=$PATH:/usr/local/mongodb/bin #在最后一行添加
root@kali:/usr/local/mongodb/bin# mongo
MongoDB shell version v4.2.2
connecting to: mongodb://127.0.0.1:27017/?compressors=disabled&gssapiServiceName=mongodb
2020-01-03T11:40:35.920+0800 E QUERY [js] Error: couldn't connect to server 127.0.0.1:27017, connection attempt failed: SocketException: Error connecting to 127.0.0.1:27017 :: caused by :: Connection refused :
connect@src/mongo/shell/mongo.js:341:17
@(connect):2:6
2020-01-03T11:40:35.927+0800 F - [main] exception: connect failed
2020-01-03T11:40:35.927+0800 E - [main] exiting with code 1
聯(lián)系客服