问题描述
在mac上启动redis后,没有错误提示,但连接不上
(base) C02FRH0XMD6M:work haiping.lai$ brew services start redis
==> Tapping homebrew/services
Cloning into '/usr/local/Homebrew/Library/Taps/homebrew/homebrew-services'...
remote: Enumerating objects: 1863, done.
remote: Counting objects: 100% (370/370), done.
remote: Compressing objects: 100% (124/124), done.
remote: Total 1863 (delta 272), reused 281 (delta 241), pack-reused 1493
Receiving objects: 100% (1863/1863), 518.10 KiB | 479.00 KiB/s, done.
Resolving deltas: 100% (827/827), done.
Tapped 1 command (44 files, 662.7KB).
==> Successfully started `redis` (label: homebrew.mxcl.redis)
(base) C02FRH0XMD6M:work haiping.lai$ redis-cli
Could not connect to Redis at 127.0.0.1:6379: Connection refused
not connected>
(base) C02FRH0XMD6M:work haiping.lai$ brew services start redis
Bootstrap failed: 5: Input/output error
Error: Failure while executing; `/bin/launchctl bootstrap gui/510 /Users/haiping.lai/Library/LaunchAgents/homebrew.mxcl.redis.plist` exited with 5.
(base) C02FRH0XMD6M:work haiping.lai$ lsof -i:6379
(base) C02FRH0XMD6M:work haiping.lai$ ps -ef | grep redis
510 87280 1490 0 9:47上午 ttys002 0:00.00 grep redis
解决方法
启动时加上sudo:sudo brew services stop redis
(base) C02FRH0XMD6M:work haiping.lai$ sudo brew services stop redis
Warning: Service `redis` is not started.
(base) C02FRH0XMD6M:work haiping.lai$ redis-cli -h 127.0.0.1 -p 6379
Could not connect to Redis at 127.0.0.1:6379: Connection refused
not connected>
(base) C02FRH0XMD6M:work haiping.lai$ brew services start redis
==> Successfully started `redis` (label: homebrew.mxcl.redis)
(base) C02FRH0XMD6M:work haiping.lai$ redis-cli -h 127.0.0.1 -p 6379
Could not connect to Redis at 127.0.0.1:6379: Connection refused
not connected>
(base) C02FRH0XMD6M:work haiping.lai$ sudo brew services start redis
Warning: Taking root:admin ownership of some redis paths:
/usr/local/Cellar/redis/6.2.6/bin
/usr/local/Cellar/redis/6.2.6/bin/redis-server
/usr/local/opt/redis
/usr/local/opt/redis/bin
/usr/local/var/homebrew/linked/redis
This will require manual removal of these paths using `sudo rm` on
brew upgrade/reinstall/uninstall.
Warning: redis must be run as non-root to start at user login!
==> Successfully started `redis` (label: homebrew.mxcl.redis)
(base) C02FRH0XMD6M:work haiping.lai$ redis-cli -h 127.0.0.1 -p 6379
127.0.0.1:6379>