Home > Database > Redis > body text

How to use redis command

(*-*)浩
Release: 2019-11-26 09:36:55
Original
1476 people have browsed it

How to use redis command

Redis commands are used to perform operations on the redis service.

To execute commands on the redis service, a redis client is required. The Redis client is in the redis installation package we downloaded before.

# grammar (Recommended learning: redis video tutorial )

# Redis's basic syntax is:

$ redis-cli
Copy after login

Example

The following example explains how to start the redis client:

Start the redis client, open the terminal and enter the command redis-cli. This command will connect to the local redis service.

$redis-cli
redis 127.0.0.1:6379>
redis 127.0.0.1:6379> PING
PONG
Copy after login

In the above example, we connect to the local redis service and execute the PING command, which is used to detect whether the redis service is started.

Execute commands on the remote service

If you need to execute commands on the remote redis service, we also use the redis-cli command.

Syntax

$ redis-cli -h host -p port -a password
Copy after login

Example

The following example demonstrates how to connect to the host as 127.0.0.1 and the port as 6379, The password is mypass on the redis service.

$redis-cli -h 127.0.0.1 -p 6379 -a "mypass"
redis 127.0.0.1:6379>
redis 127.0.0.1:6379> PING
PONG
Copy after login

For more Redis-related technical articles, please visit the Redis Getting Started Tutorial column to learn!

The above is the detailed content of How to use redis command. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!