224
votes

I have a Linux server with Redis installed and I want to connect to it via command line from my local Linux machine.

Is it possible to install redis-cli only (without redis-server and other tools)?

If I just copy redis-cli file to my local machine and run it, I have the following error:

./redis-cli: /lib/x86_64-linux-gnu/libc.so.6: version `GLIBC_2.14' not found (required by ./redis-cli)
13
Well, 1. it is not surprising that just copying the executable does not work: most likely you have different architecture and library versions, that cannot work. 2. you should consult the software management system your distribution provides and see what redit packages it provides. Then installing one of those shoudl only require a single click. You should never do a wild installation of stuff into a Linux system if you can use the software management instead.arkascha
@arkascha Thank you for your tip. I'm quite new to Linux so this information is very useful for meOleg
You mean you are a developer working under a Linux environment, but you never used your systems software management system? What distribution do you use?arkascha
You might also be interested in a package called 'hiredis' which offers a minimalistic c client for redis. No ready-to-use cli client though.arkascha
What about git clone [email protected]:antirez/redis.git then cd src && make redis-cli?deltheil

13 Answers

412
votes

Ubuntu (tested on 14.04) has package called redis-tools which contains redis-cli among other tools. To install it type:

sudo apt-get install redis-tools
103
votes

Instead of redis-cli you can simply use nc!

nc -v --ssl redis.mydomain.com 6380

Then submit the commands.

44
votes

From http://redis.io/topics/quickstart

wget http://download.redis.io/redis-stable.tar.gz
tar xvzf redis-stable.tar.gz
cd redis-stable
make redis-cli
sudo cp src/redis-cli /usr/local/bin/

With Docker I normally use https://registry.hub.docker.com/_/redis/. If I need to add redis-cli to an image I use the following snippet.

RUN cd /tmp &&\
    curl http://download.redis.io/redis-stable.tar.gz | tar xz &&\
    make -C redis-stable &&\
    cp redis-stable/src/redis-cli /usr/local/bin &&\
    rm -rf /tmp/redis-stable
31
votes

To install 3.0 which is the latest stable version:

$ git clone http://github.com/antirez/redis.git 
$ cd redis && git checkout 3.0 
$ make redis-cli 

Optionally, you can put the compiled executable in your load path for convenience:

$ ln -s src/redis-cli /usr/local/bin/redis-cli
22
votes

In my case, I have to run some more steps to build it on RedHat or Centos.

# get system libraries
sudo yum install -y gcc wget

# get stable version and untar it
wget http://download.redis.io/redis-stable.tar.gz
tar xvzf redis-stable.tar.gz
cd redis-stable

# build dependencies too!
cd deps
make hiredis jemalloc linenoise lua geohash-int
cd ..

# compile it
make

# make it globally accesible
sudo cp src/redis-cli /usr/bin/
16
votes

For centOS, maybe can try following steps

cd /tmp
wget http://download.redis.io/redis-stable.tar.gz
tar xvzf redis-stable.tar.gz
cd redis-stable
make
cp src/redis-cli /usr/local/bin/
chmod 755 /usr/local/bin/redis-cli
9
votes

Using Docker, you may run this command to get Redis CLI:

docker run -it --rm redis:alpine redis-cli -h redis.mycompany.org -p 6379

where redis is the redis docker image from Docker Hub,
redis-cli is pre-installed in that image, and all after that are parameters to redis-cli:
-h is hostname to connect to,
-p is apparently the port to connect to.

You could also create an alias using the above command

alias redis-cli='docker run --rm --network=host redis:alpine redis-cli'

Which could be added to .bashrc if your using Bash

7
votes

To expand on @Agis's answer, you can also install the Redis CLI by running

$ git clone -b v2.8.7 [email protected]:antirez/redis.git
$ make -C redis install redis-cli /usr/bin

This will build the Redis CLI and toss the binary into /usr/bin. To anyone who uses Docker, I've also built a Dockerfile that does this for you: https://github.com/bacongobbler/dockerfiles/blob/master/redis-cli/Dockerfile

6
votes

You can also use telnet instead

telnet redis-host 6379

And then issue the command, for example for monitoring

monitor
1
votes
# get system libraries
sudo yum install -y gcc wget

# get stable version and untar it
wget http://download.redis.io/redis-stable.tar.gz
tar xvzf redis-stable.tar.gz
cd redis-stable
make redis-cli

If the build fails / make command fails, then :

Removing all line with _Atomic from src/server.h and src/networking.c should makes the compile complete.

# make it globally accesible
sudo cp src/redis-cli /usr/local/bin/
0
votes

you may scp it from your redis machine if you have one, its just single binary. Or copy with nc if private network (this method is insecure):

redisclient: nc -l 8888 > /usr/local/bin/redis-cli
redisserver: cat /usr/local/bin/redis-cli | nc redisclient 8888
0
votes

I made a simple pure-go solution, which is under development.

redis-cli: https://github.com/holys/redis-cli

Build once, and run everywhere. Fully portable.

Please feel free to have a try.

0
votes

There are many way to install radis-cli. It comes with redis-tools and redis-server. Installing any of them will install redis-cli too. But it will also install other tools too. As you have redis-server installed somewhere and only interested to install redis-cli. To install install only redis-cli without other unnecessary tools follow below command

cd /tmp
wget http://download.redis.io/redis-stable.tar.gz
tar xvzf redis-stable.tar.gz
cd redis-stable
make
cp src/redis-cli /usr/local/bin/
chmod 755 /usr/local/bin/redis-cli