How to Install Redis on Mac by Homebrew / Source?

Generally, there are two ways to install Redis on Mac: install Redis on Mac by using Homebrew command, and install Redis on Mac from Source. Let’s dive into how to Install Redis on Mac.

How to Install Redis on Mac by Homebrew

Homebrew is the easiest way to install Redis on macOS. This is the recommended way to Redis on Mac. It’s very easy to install Redis on Mac by using the Homebrew command.

Step 1: Make sure you have Homebrew installed.

Run the command to make sure your Mac has installed Homebrew.

$ brew --version

If Homebrew has not been installed on your Mac, you can follow the Homebrew installation instructions to install it.

Step 2: Install Redis

In your terminal, run the command to install Redis.

brew install redis

This command will automatically install Redis on your Mac.

Step 3: Starting and stopping Redis

Now, you can test the Redis installation, just run the redis-server executable from the command line.

redis-server &

or

brew services start redis

Step 4: Connect to Redis

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

redis-cli

If you can connect Redis, it means that you have installed Redis on Mac.

Install Redis on Mac by Homebrew

How to Install Redis on Mac from Source Install Package?

Step 1: Download the latest stable version of Redis

To download the latest stable version of Redis from the Redis downloads site.

wget https://download.redis.io/redis-stable.tar.gz

Step 2: Compiling Redis

tar -xzvf redis-stable.tar.gz
cd redis-stable
make

If there is no errors, you’ll find several Redis binaries in the src directory, including:

  • redis-server: the Redis Server itself
  • redis-cli is the command line interface utility to talk with Redis.
  • redis-benchmark

It’s a good idea to run the ‘make test’.

Step 3: Running Redis

Using the redis-server & command to run redis-server in background.

redis-server &

Generally, you will see the result of running Redis in the terminal like this:

Install Redis on Mac from Source Install Package

Step 4: Connect to Redis

After Redis is running, you can test it by running redis-cli to connect to Redis:

redis-cli

If you can connect Redis, it means you rightly installed Redis on your Mac.