问题描述
每当我尝试从终端执行命令tClients (Table)
AClientID (Primary Key,INT)
sClientName (VARCHAR(255))
时,都会弹出此错误:
mongo
我一直遵循this教程,以便在MacBook Pro上安装mongo,但由于创建了MongoDB shell version v4.4.0
connecting to: 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 :: Connection refused :
connect@src/mongo/shell/mongo.js:362:17
@(connect):2:6
exception: connect failed
exiting with code 1
而失败。后来,this的另一篇文章出现在我身上。第二个命令命令我从终端运行下一段代码:
/data/db
但是出现了我一开始粘贴的相同错误。
我能做些什么来安装并保持mongo运行吗?
操作系统: macOS Catalina-10.15.16
谢谢!
解决方法
尝试:
brew services start mongodb/brew/mongodb-community
,
对于macOS用户:
1,重新安装mongodb-community
brew uninstall mongodb-community
brew cleanup
brew install mongodb/brew/mongodb-community
2,配置并启动
sudo mongod --config /usr/local/etc/mongod.conf
brew services start mongodb-community