Install Redis on WSL

Raymond Tang Raymond Tang 0 8210 5.11 index 2/1/2021

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

  1. Open Debian distro through WSL command:

    wsl -d Debian
    
  2. Update Debian packages:

    sudo apt update
    

    You need to type user password.

  3. Install Redis using the following command:

    sudo apt install redis-server
    

    Type Y to continue when asked.

  4. Wait until the installation is completed.

  5. 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

  1. Start redis server using the following command:

    sudo service redis-server start
    # or
    sudo /etc/init.d/redis-server start
    
  2. 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 3. Alternatively, we can use redis-cli to ping:

```
redis-cli ping
PONG
```

The command prints out PONG when the service is running.
  1. Use redis-cli:

    $ redis-cli127.0.0.1:6379> set mykey somevalueOK127.0.0.1:6379> get mykey"somevalue"127.0.0.1:6379>
    

    The above commands set a key named mykeywith value as somevalue; and then the value is retrieved via get command.

  2. Type quitto quite redis CLI.

  3. Run the following command to stop Redis server:

    sudo /etc/init.d/redis-server stop
    # or
    sudo service redis-server stop
    
windows10 wsl

Join the Discussion

View or add your thoughts below

Comments