Problem scenario description
我按照mongodb官网的 ubantu apt源安装完之后,命令行键入mongod -version是正常的:
我单独建立存储我项目的数据文件夹,其结构为:
-pile_db
-data
-log
-mongo.log
我在命令行键入 mongod --dbpath ~/pile_db/data --logpath ~/pile_db/log/mongo.log -logappend --fork
指定了data目录,log日志位置。此时系统中的mongod服务是已经开启的。
At this time, a system error occurred:
I checked the records in the log/mongo.log file:
said it was occupied by 0.0.0.0:27017, but I did not set up other mongo libraries. .
mongo did not connect to the data I set myself
Instead, this time the command line enters mongo
but this entry is not the data of the pile_db I pointed to.
I don’t understand how to change it. Please give me some advice. I’ve just come into contact with mongo. I see other tutorials and the connection goes smoothly, so I’m a little embarrassed.
If I remember correctly, Ubuntu may have started a MongoDB database after installing MongoDB.
Check the method of starting and stopping the mongodb service under Ubuntu. If I remember correctly, service mongod start/stop/restart.
Or you can change the port number of MongoDB that you start separately.
Love MongoDB! Have Fun!