Install Redis on WSL
Redis (Remote Dictionary Server) is one of the most popular key-value in-memory NoSQL databases. It is also commonly used in containers.
Prerequisites
Before installing Redis server on WSL, please ensure you have WSL enabled on your Windows 10 system.
Follow Install Windows Subsystem for Linux on a Non-System Drive to install WSL on a non-C drive.
This tutorial provides steps to install Redis on WSL Debian distro. You can follow similar steps to install it in other Linux distros.
Step by step guide
- Open Debian distro through WSL command:
wsl -d Debian
- Update Debian packages:
sudo apt update
You need to type user password.
- Install Redis using the following command:
sudo apt install redis-server
Type Y to continue when asked.
- Wait until the installation is completed.
- Verify SQLite version:
$ redis-server --version Redis server v=3.2.6 sha=00000000:0 malloc=jemalloc-3.6.0 bits=64 build=a2cab475abc2115e
Test Redis server
- Start redis server using the following command:
sudo service redis-server start # or sudo /etc/init.d/redis-server start
- Check the status of the server
sudo service redis-server status # or sudo /etc/init.d/redis-server status
The command prints out the following text:
[....] redis-server is running - Alternatively, we can use redis-cli to ping:
redis-cli ping PONG
The command prints out PONG when the service is running.
- Use redis-cli:
$ redis-cli
127.0.0.1:6379> set mykey somevalue
OK
127.0.0.1:6379> get mykey
"somevalue"
127.0.0.1:6379>The above commands set a key named mykey with value as somevalue; and then the value is retrieved via get command.
- Type quit to quite redis CLI.
- Run the following command to stop Redis server:
sudo /etc/init.d/redis-server stop # or sudo service redis-server stop