Python uses pymongo to connect to the local database prompt to actively reject?

the problem is like a question. I"ll describe the details in detail.
asked the same question on Zhihu

when I was self-taught python crawler, I came into contact with MongoDB, to install according to the URL given by rookie tutorial . Visual observation is quite normal. I put forward warning, but checked it, that is to say, I don"t have a user name, password, local database or something. As shown below:

mongod.cfg:


shellmongo:

:

chrome"localhost:27107" :

:


:

at this time, my windows service MongoDB is running, and I should also be running MongoDB ( actually, I"m not sure if it"s enabled, but I already have the interface of the first picture in CMD, so I open it by default )

. So much for the description of the

problem. The following is some of the situation of my computer, and the attempts made, say it for good analysis.

-split line-

  1. there is a saying on the Internet that 27107 may not be open or anything. I have already set it up in the inbound rules of the firewall. Useless
  2. has tried to hang SSR and unhung SSR, respectively, and it doesn"t work either.
  3. found someone who said there was a problem with ip. I tried to set ip to 0.0.0.0 (actually, I don"t think it"s possible, but I also tried)
  4. others say that mongodb did not start. I don"t know what to say. I can connect with the official MongoDB Compass and operate the data in shell. This is enabled by default, right?
  5. is in the configuration file, and I specifically wrote the port as 27107.
  6. I have a desktop computer, not a network cable, but a wifi receiver, and the tplink at home is relayed through a millet signal amplifier, right? I don"t quite understand, but the signal in the room is weak, so I use an amplifier to search the amplifier wifi
  7. it is seriously suspected that the network does not know that there is a problem with that link. Of course, it"s also possible that I was inexperienced and didn"t find anything. The boss who wants to solve the problem can put forward his own ideas or ask me for some details. Thank you again and again!
Feb.28,2021

it's a little confusing, and I say a little bit:

visual inspection is quite normal. I put forward warning, but I checked it, which probably means that I don't have a user name, password, local database or something.

Yes, this is just a warning that there are some operational risks that do not comply with best practices, but do not affect your use. It's just that you should consider solving these problems before you go to the production environment.

There is no problem with the

configuration file. You have entered mongo shell, in your screenshot and can start executing the CRUD command of mongo (just like entering mysql shell). But you execute mongo, in mongo shell and you don't know what it means. Mongo.exe is a bash command, and after running it, you just enter mongo shell, and you are already in shell. How did you get into this shell? Isn't it just the implementation of mongo?

as for chrome connection localhost:27017 , many people make such mistakes, which may be misleading from some tutorials. For example, MySQL listens localhost:3306 by default, and SQLServer listens localhost:1433 by default. Will you connect localhost:1433 / localhost:3306 in the influencer? What will be the effect after the connection? There will also be errors in the screenshot. It doesn't make sense to connect like this. To connect to port 27017, you should use mongo shell, that is, mongo.exe: mongo.exe-- host localhost:27017

finally, I will talk about the problem of Python. You have already connected to MongoDB, through shell, so there is no problem with the server running. The reason why the Python cannot be connected may be that there is a problem with the resolution of the domain name localhost. You can use

instead.
MongoClient('127.0.0.1', '27017')

try and see what the result is.

MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1c051c7-32753.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1c051c7-32753.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?