Redis is an open-source data storage solution. It is primarily used as a database, cache storage, or message broker due to the way it stores key-value pairs.
Redis stands out with its flexibility and high performance, wide language support, and high availability.
In this tutorial, you will learn several ways to install and configure Redis on your Mac computer.
- A system running macOS Catalina
- Access to the terminal window
- A user with admin-level privileges
Installing Redis on Mac
There are two ways to install Redis on Mac:
- Installing Redis from scratch.
- Using package management software, like Homebrew.
Homebrew automates most of the installation process, making it quick and easy to add Redis to your system. It also provides more options when configuring Redis, and makes uninstalling it a lot simpler.
Option 1: Install Redis on Mac With Homebrew
If you don’t have Homebrew, install it with the following command:
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install.sh)"
If you already have a copy of Homebrew installed, update it by using:
With an up-to-date version of Homebrew, install Redis by using the command:
brew install redis
Using this command produces the following output:
Option 2: Install Redis on Mac Without Homebrew
The second method enables you to install Redis on Mac without Homebrew.
To install Redis without Homebrew, use the following commands:
mkdir redis && cd redis
curl -O http://download.redis.io/redis-stable.tar.gz
tar xzvf redis-stable.tar.gz
sudo make install
mkdir redis && cd redis– Creates a folder called ‘redis’ and moves you to the newly created folder.
curl -O http://download.redis.io/redis-stable.tar.gz– Downloads the Redis installation archive.
tar xzvf redis-stable.tar.gz– Unpacks the ‘redis-stable‘ installation archive.
cd redis-stable– Moves you to the ‘redis-stable’ folder.
The remaining commands install the Redis software.
Note: NoSQL databases, like Redis, are meant to run efficiently in distributed clusters that scale out horizontally. Using Docker to deploy Redis in a container makes horizontal scaling a routine, straightforward process.
Starting and Configuring Redis on Mac
Depending on the installation method used, there are two ways to launch Redis on your system.
If you installed Redis using Homebrew, use Homebrew to launch it:
brew services start redis
If you installed Redis without Homebrew, use the following code:
Modify your Redis instance by using the commands listed below.
Launch Redis on Boot
To have Redis launch on system boot, use:
ln -sfv /usr/local/opt/redis/*.plist ~/Library/LaunchAgents
Stop Redis from Launching on Boot
To stop Redis from starting upon system boot, use:
launchctl unload ~/Library/LaunchAgents/homebrew.mxcl.redis.plist
Start Redis Server
There are two ways to start your Redis server:
- Using the
- Using the Redis configurations file.
When starting Redis with the
launchctl command, use the following syntax:
launchctl load ~/Library/LaunchAgents/homebrew.mxcl.redis.plist
If you want to start Redis using the configuration file, use:
By default, the Redis configuration file is located at
Test if Redis Server is Running
Ping your Redis server to verify if it’s running:
The system responds with a ‘pong’ if the server is up and running.
Uninstalling Redis on Mac
To uninstall Redis, use Homebrew with the following command:
brew uninstall redis
Note: Remember to also remove Redis files from your hard-drive by using:
After following this tutorial, you now know how to install, configure, and uninstall Redis on your Mac computer.
For more helpful tips on using Redis, check out our comprehensive guide to Redis data types.