Mac(os x): Is there a way to install ONLY redis-cli?
Asked Answered
V

7

183

I tried to run brew install redis-cli and googled, but found nothing. Any ideas?

Virus answered 26/9, 2016 at 13:31 Comment(3)
brew install redis only installs 6 files as it is - and one of them is a symlink!Highway
My console says: /usr/local/Cellar/redis/3.2.0: 10 files 1.7M:) But actually, no matter I just didn't notice that it doesn't run a redis service by default. If you add your comment as an answer(with some details), I'll accept itVirus
Sadly seems no. I also looking for the same thingGuidance
H
190

If you install redis with homebrew, you can see what's in the package like this:

brew install redis
brew ls redis

You will see that it only installs very few files indeed anyway:

/usr/local/Cellar/redis/3.2.3/bin/redis-benchmark
/usr/local/Cellar/redis/3.2.3/bin/redis-check-aof
/usr/local/Cellar/redis/3.2.3/bin/redis-check-rdb
/usr/local/Cellar/redis/3.2.3/bin/redis-cli
/usr/local/Cellar/redis/3.2.3/bin/redis-sentinel
/usr/local/Cellar/redis/3.2.3/bin/redis-server
/usr/local/Cellar/redis/3.2.3/homebrew.mxcl.redis.plist

Or, you can look directly in homebrew's Cellar, like this:

ls -lR /usr/local/Cellar/redis/3.2.3
total 40
-rw-r--r--  1 mark  admin  1487  2 Aug 10:00 COPYING
-rw-r--r--  1 mark  admin   376  9 Aug 10:34 INSTALL_RECEIPT.json
-rw-r--r--  1 mark  admin  6834  2 Aug 10:00 README.md
drwxr-xr-x  8 mark  admin   272  2 Aug 10:00 bin
-rw-r--r--  1 mark  admin   785  9 Aug 10:34 homebrew.mxcl.redis.plist

/usr/local/Cellar/redis/3.2.3/bin:
total 3440
-r-xr-xr-x  1 mark  admin   67668  2 Aug 10:00 redis-benchmark
-r-xr-xr-x  1 mark  admin   13936  2 Aug 10:00 redis-check-aof
-r-xr-xr-x  1 mark  admin  768704  2 Aug 10:00 redis-check-rdb
-r-xr-xr-x  1 mark  admin  129712  2 Aug 10:00 redis-cli
lrwxr-xr-x  1 mark  admin      12  2 Aug 10:00 redis-sentinel -> redis-server
-r-xr-xr-x  1 mark  admin  768704  2 Aug 10:00 redis-server

So, a lot of it is the licence, README and, of the 6 binaries, one is a symlink anyway. So it is not a heavy-weight installation with loads of services and config files anyway.


By the way, you could always pull and run the docker redis-cli without installing anything:

docker run --rm -it redis:alpine redis-cli -h 192.168.0.8     # change to your Redis host's IP

If you actually just want to install the very least software you possibly can, you don't actually have to install anything! The Redis protocol is pretty simple, so you can build up a command in bash and send it yourself like this:

#!/bin/bash
################################################################################
# redis.sh
# Very, very simplistic Redis client in bash
# Mark Setchell
# Usage:
# redis.sh SET answer 42
#
# Ref: https://redis.io/topics/mass-insert
################################################################################
if [ $# -lt 2 ] ; then
    echo "Usage: redis.sh SET answer 42" >&2
    exit 1
fi

# Build protocol string
protocol="*$#\r\n"

for var in "$@" ; do
   protocol+="$" 
   protocol+="${#var}\r\n${var}\r\n"
done

# Send to Redis on default port on local host - but you can change it
printf "$protocol" > /dev/tcp/localhost/6379
Highway answered 26/9, 2016 at 15:32 Comment(7)
to run this you first need to install redis otherwise it will give you error like this Error: No such keg: /usr/local/Cellar/redis to install just run "brew install redis" Then run "brew ls redis"Winy
In my case, showing - brew ls redis -> Error: No such keg: /usr/local/Cellar/redisBencher
@SandeepanNath brew ls only shows you what was installed. you have to first brew install redis to see itSimonides
Getting 'Error: No available formula with the name "redis-cli"' in 2020 as well.Jennifer
@Jennifer I didn't suggest any formula with the name redis-cli so you cannot have got that message from running my suggested answer.Highway
@MarkSetchell Don't remember what triggered this error message but I simply pasted what I saw on terminal. Thanks for clarification.Jennifer
Very simple protocol indeed. As a bonus on your shell script, if you want to talk to any Redis host, replace the last line with printf "$protocol" | nc <redis host> 6379 -v Replace <redis host>. Can easily modify the script to accept host as input argument too. Read the manual of nc for more details in this very useful Transport Layer network command.Demarcusdemaria
S
181
brew tap ringohub/redis-cli

brew update && brew doctor

brew install redis-cli
Spruce answered 17/4, 2019 at 17:30 Comment(7)
This is the only answer that properly answers the question and should be the accepted answer.Octopod
Who/what is "ringohub" and why should I install software from it?Invert
I'm not getting the latest version of redis-cli with thisUbana
Any way to get @Virus to accept this answer? I understand that this question is three years old, but still...Ominous
I agree with Henrik, for security reasons we should not install packages from unknown sources. But still, I upvote this answer. It was the most helpful for me.Mangan
Agree with @Henrik, this is an unknown source. I would mark this as the accepted answer if it was from a reliable sourceExcursionist
You can view the contents of the package with brew info redis-cli which references github.com/aoki/homebrew-redis-cli/blob/HEAD/redis-cli.rb which is installing official code from github.com/antirez/redisMitre
S
38

This is not a proper installation of redis-cli, BUt I get my work done. I get it working using npm, I installed redis-cli a javascript library.

$ npm install -g redis-cli                  
    /Users/toni/.nvm/versions/node/v8.9.4/bin/rdcli -> /Users/toni/.nvm/versions/node/v8.9.4/lib/node_modules/redis-cli/bin/rdcli
    + [email protected]
    updated 1 package in 1.07s

then using the console:

$ rdcli                                 
127.0.0.1:6379> keys incident::sequence
1) incident::sequence
127.0.0.1:6379> GET incident::sequence
570
127.0.0.1:6379> config get dir
1) dir
2) /data
127.0.0.1:6379> exit
Selangor answered 4/4, 2019 at 13:6 Comment(2)
This is actually how Redislabs suggest doing it on there website -redislabs.com/blog/…Dermatome
Warning!: I have been using rdcli for a while however just realized it doesn't support full functionality. For instance, I tried to execute "Memory Stats" it was giving an error saying "elem.map is not a function". After switching to native redis-cli, it worked.Caudle
I
5

I installed the redis-cli nodejs module:

yarn global add redis-cli

Then ran redis client:

rdcli

and redis client connected, redis REPL shell was activated

Iquique answered 26/8, 2020 at 18:11 Comment(0)
H
2

You can use telnet [host [port]] to connect to redis:

telnet localhost 6379
Hypodermic answered 18/10, 2021 at 11:9 Comment(0)
W
2
Wards answered 12/6, 2023 at 11:32 Comment(0)
Z
1

First you need to check if redis is installed or not. Command- telnet localhost 6379

if not then you can add it with brew or yarn.

for Yarn- yarn global add redis-cli for brew- brew install redis for NPM- $npm install -g redis-cli

Zephaniah answered 18/10, 2021 at 11:13 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.