Aliweb
Aliweb

Reputation: 1951

redis command-line commands seem not working

I have a silly problem with running redis commands in ubuntu 12 terminal , maybe my question is silly , if so , consider I'm a newbie user of redis and ubuntu.

I have installed redis 2.6.7 according to the official guide http://redis.io/download

Now I run these commands :

redis-server

It says it's now connected but after that nothing happens after each command I enter, so I press (Ctrl + z) and then type :

redis-cli

and it seems to connect successfully and something like this appears :

redis 127.0.0.1:6379>

So I type some commands but nothing happens. for example this command :

get users:leto

and just a blank line appears. (seems it's waiting for something to complete the command)

So what's the problem according to this? am I missing a simple point or there's another problem?

Thanks for your help , I'm really confused.

Upvotes: 3

Views: 9480

Answers (3)

Brent
Brent

Reputation: 1498

In my case I was connecting to a tls enabled redis server so the prompt was hanging. adding --tls fixed this for me.

Upvotes: 1

ZengJuchen
ZengJuchen

Reputation: 4811

The simple solution is at the bottom if you are in hurry.

I've met the same problem, facing a running redis server and types command and wait it until bored. And I even don't know there is a redis-cli command!

After I saw this question. I went back to my terminal and type redis-cli into my redis-sever terminal screen. As you know, nothing happens still.

But a great idea hit me. I opened another terminal, and type into redis-cli.

redis-cli

Now a pretty redis interface prompt out, looks like

127.0.0.1:6379>

Wow! Thrilling. Let's try if it works

127.0.0.1:6379>APPEND zen Solver_of_this_problem
(interger) 22
127.0.0.1:6379>GET zen
'Solver_of_this_problem'

Awesome! I can handle my redis now!

So the secret is:

Open two terminals, one for redis-sever, and another for redis-cli.

Upvotes: 1

ghik
ghik

Reputation: 10764

It seems to me that you have suspended redis-server by pressing Ctrl+Z, so it cannot respond to anything (redis-cli probably did not connect to the server but it is written so that it doesn't fail immediately in such case). You can resume redis-server in background by issuing bg command after pressing Ctrl+Z.

I would suggest you to read about job control in UNIX shells to understand this issue better.

Upvotes: 6

Related Questions