在 macOS 上安装 Redis

使用 Homebrew 在 macOS 上安装和启动 Redis

Redis 堆栈 Redis 社区版

本指南向您展示如何使用 Homebrew 在 macOS 上安装 Redis。Homebrew 是在 macOS 上安装 Redis 的最简单方法。如果您希望从 macOS 上的源文件构建 Redis,请参阅从源安装 Redis

注意:
Redis 社区版的 Homebrew 发行版仅在 macOS 上受支持。

先决条件

首先,确保您已安装 Homebrew。在终端中,运行:

brew --version

If this command fails, you'll need to follow the Homebrew installation instructions.

Installation

From the terminal, run:

brew install redis

This will install Redis on your system.

Starting and stopping Redis in the foreground

To test your Redis installation, you can run the redis-server executable from the command line:

redis-server

If successful, you'll see the startup logs for Redis, and Redis will be running in the foreground.

To stop Redis, enter Ctrl-C.

Starting and stopping Redis using launchd

As an alternative to running Redis in the foreground, you can also use launchd to start the process in the background:

brew services start redis

This launches Redis and restarts it at login. You can check the status of a launchd managed Redis by running the following:

brew services info redis

If the service is running, you'll see output like the following:

redis (homebrew.mxcl.redis)
Running: ✔
Loaded: ✔
User: miranda
PID: 67975

To stop the service, run:

brew services stop redis

Connect to Redis

Once Redis is running, you can test it by running redis-cli:

redis-cli

Test the connection with the ping command:

127.0.0.1:6379> ping
PONG

You can also test that your Redis server is running using Redis Insight.

Next steps

Once you have a running Redis instance, you may want to:

RATE THIS PAGE
Back to top ↑