Error: couldn't connect to server 127.0.0.1:27017, connection attempt failed: SocketException

insert image description here

question

The last window of mongod entered in the bin directory of the mongodb installation directory in cmd is closed

Solution

1.data file

After MongoDB is installed, create a data folder in the root directory of MongoDB, and then create a db folder in the data folder
insert image description here
insert image description here

2. Enter the command

Enter mongod.exe --dbpath D:\MongoDB\data
D:\MongoDB\data (represents your storage location, here is my location) in cmd and
open the cmd command again and enter mongo
insert image description here

Guess you like

Origin blog.csdn.net/weixin_45664911/article/details/106119748