How to set up ClickHouse locally in windows

How to set up ClickHouse locally in windows

Hello everyone! In this post, I will demonstrate how to run ClickHouse locally on Windows.

ClickHouse Installation

  1. To run ClickHouse, we need a Linux environment. Therefore, we will download WSL (Windows Subsystem for Linux), enabling us to run a Linux environment on Windows.

  2. Open Command Prompt in administrator mode by right-clicking and selecting "Run as administrator." Then, type the command "wsl --install."

wsl --install

You will see something like this

  1. After that, you will need to create a Linux user and set a password for that user. Create a user with any name you want and set a password that you will remember, as you may need this password for installing any other libraries in your subsystem.

    Now run the below command to install ClickHouse

curl https://clickhouse.com/ | sh

  1. After installation is completed. Start the clickHouse server.
./clickhouse server
  1. Keep this server running in the background, open new Linux terminal and run the ClickHouse client
./clickhouse client

There you go, you can now run ClickHouse on your local machine.

Running queries on ClickHouse

Let's create a new table. Run the below query to create a table.

CREATE TABLE TEST
(
    `userId` UInt64,
    `name` String,
    `password` String,
    `description` Nullable(String)
)
ENGINE = MergeTree
ORDER BY tuple()

Let's see if we get the table created. To see the list of tables in our ClickHouse client run the below query.

SHOW TABLES

Now, let's insert some data in the table.

INSERT INTO TEST (*) FORMAT Values
(1, 'Siddhant', 'password', 'test description'), 
(2, 'user2', 'password2', 'test description 2'), 
(3, 'user3', 'password3', 'test description 3')

To see the data run select the query

SELECT * FROM TEST

You will see the following result

At the end of each query, ClickHouse shows how much time it took to process the given query. Additionally, it displays how many rows ClickHouse processed per second to execute the query.

This is how you can run ClickHouse locally. Please let me know if this blog was helpful, and if you have any doubts, write them down in the comments section. I will do my best to answer them.

Did you find this article valuable?

Support Siddhant Bytes by becoming a sponsor. Any amount is appreciated!