To start Redis client, open the terminal and type the command redis-cli. This will connect to your local server and now you can run any command. In the above example, we connect to Redis server running on the local machine and execute a command PING, that checks whether the server is running or not.
you can do it by this way. $redis = new Redis(); $redis->connect('127.0. 0.1', 6379); echo $redis->ping(); and then check if it print +PONG , which show redis-server is running.
The Redis command line interface ( redis-cli ) is a terminal program used to send commands to and read replies from the Redis server.
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
Instead of redis-cli
you can simply use nc
!
nc -v --ssl redis.mydomain.com 6380
Then submit the commands.
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
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
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/
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
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
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With