我尝试在shell中连接*mongo "mongodb+srv://cluster0.mi3o1.mongodb.net/test" --username cristian*
。
但是,它看起来像是试图连接到:*mongodb://127.0.0.1:27017/?compressors=disabled&gssapiServiceName=mongodb*
我得到错误
*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 :: No connection could be made because the target machine actively refused it. :
connect@src/mongo/shell/mongo.js:374:17
@(connect):2:6
exception: connect failed
exiting with code 1
bash: mongodb+srv://cluster0.mi3o1.mongodb.net/test: No such file or directory*
我已经创建了集群,使用管理员角色用户cristian访问数据库,将我的IP和所有IP0.0.0.0/0
列入白名单,创建了一个新数据库,加载了示例数据库,打开了端口27015
,27016
,27017
并在portquiz.net上进行了测试。请帮助!
终端prtscn
非常感谢D. SM的帮助,看起来是我的.bash_profile有问题。当我复制和粘贴这两个路径时,我不知道为什么终端会写最后一个"在另一行,中间有一些空格。我重写了两行,没有空格,像这样:
alias mongod="/c/Program files/MongoDB/Server/4.4/bin/mongod.exe"alias MongoDB ="/c/Program Files/MongoDB/Server/4.4/bin/MongoDB .exe">
并且成功了