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) 1417 Answers
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 Note that on Ubuntu 16.04+ the command is a little bit different:
sudo apt install redis-tools 4Instead of redis-cli you can simply use nc!
nc -v --ssl redis.mydomain.com 6380 Then submit the commands.
7wget 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 . If I need to add redis-cli to an image I use the following snippet.
RUN cd /tmp &&\ curl | tar xz &&\ make -C redis-stable &&\ cp redis-stable/src/redis-cli /usr/local/bin &&\ rm -rf /tmp/redis-stable 0To install 3.0 which is the latest stable version:
$ git clone $ 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 2In 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 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/ 1For centOS, maybe can try following steps
cd /tmp wget tar xvzf redis-stable.tar.gz cd redis-stable make cp src/redis-cli /usr/local/bin/ chmod 755 /usr/local/bin/redis-cli 2Using 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
You can also use telnet instead
telnet redis-host 6379 And then issue the command, for example for monitoring
monitor To expand on @Agis's answer, you can also install the Redis CLI by running
$ git clone -b v2.8.7 :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:
2For Amazon Linux
#sudo amazon-linux-extras install redis6 #redis-cli 2022 answer:
git clone cd redis/src/ make redis-cli sudo cp redis-cli /usr/bin/redis-cli redis-cli --version worked for me.
0you 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 I made a simple pure-go solution, which is under development.
Build once, and run everywhere. Fully portable.
Please feel free to have a try.
1There 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 tar xvzf redis-stable.tar.gz cd redis-stable make cp src/redis-cli /usr/local/bin/ chmod 755 /usr/local/bin/redis-cli 1# get system libraries sudo yum install -y gcc wget # get stable version and untar it wget 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/ for CentOS to get redis-cli without compiling it you can fetch Redis rpm from Epel repo and extract just ths tool. Here's step by step instruction
yum install -y jemalloc yum install -y yum-utils # NOTE - EPEL REPO MUST BE INSTALLED AND ENABLED RPM_URL=$(yumdownloader --urls redis | tail -n1) RPM=$(basename $RPM_URL) mkdir /tmp/redis cd /tmp/redis wget $RPM_URL rpm2cpio $RPM | cpio -idmv "./usr/bin/redis-cli" mv ./usr/bin/redis-cli /usr/bin/redis-cli rm -rf /tmp/redis /usr/bin/redis-cli --version There's a script that automatically download, build and install the latest redis-cli on Ubuntu 20.04 LTS.
To run it, copy and paste this on your terminal.
curl -sL "" | bash Or wget, in case you don't have curl installed.
wget -qO - "" | bash Feel free to look the source code:
PS.: I'm the author of this script.