Creating a TiDB Practice Environment with Four Commands in a Windows 11 Setup

Note:
This topic has been translated from a Chinese forum by GPT and might contain errors.

Original topic: win11环境四条命令创建tidb练手环境

| username: Billmay表妹

Contribution from @huanglao2002:

Environment Requirements

  1. A personal computer with Windows 11, either Home or Pro version.
  2. Preferably 16GB of RAM, but 8GB is also acceptable.
  3. The computer should be able to connect to the internet.

Installing Ubuntu 20.04 using WSL

WSL (Windows Subsystem for Linux) allows developers to run a GNU/Linux environment, including most command-line tools, utilities, and applications, without the overhead of a traditional virtual machine or dual-boot setup.

Open PowerShell and install Ubuntu 20.04:

wsl.exe --install -d Ubuntu-20.04

This command will automatically set up the system environment, download the Ubuntu 20.04 image, and install the system. Follow the system prompts to restart and set up the Ubuntu user and password. Check the Ubuntu version:

Downloading the TiUP Tool

Log into the Ubuntu virtual machine and download the TiUP tool:

jin@TABLET-PBTEB744:~$ curl --proto '=https' --tlsv1.2 -sSf https://tiup-mirrors.pingcap.com/install.sh | sh
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100 7087k  100 7087k    0     0  7661k      0 --:--:-- --:--:-- --:--:-- 7653k
WARN: adding root certificate via internet: https://tiup-mirrors.pingcap.com/root.json
You can revoke this by remove /home/jin/.tiup/bin/7b8e153f2e2d0928.root.json
Successfully set mirror to https://tiup-mirrors.pingcap.com
Detected shell: bash
Shell profile:  /home/jin/.bashrc
/home/jin/.bashrc has been modified to add tiup to PATH
open a new terminal or source /home/jin/.bashrc to use it
Installed path: /home/jin/.tiup/bin/tiup
===============================================
Have a try:     tiup playground
===============================================

jin@TABLET-PBTEB744:~$ source /home/$USER/.bashrc

The TiUP tool is now installed.

Installing TiDB

Use TiUP to install a practice environment:

jin@TABLET-PBTEB744:~$ tiup playground
tiup is checking updates for component playground ...
A new version of playground is available:
   The latest version:         v1.11.1
   Local installed version:
   Update current component:   tiup update playground
   Update all components:      tiup update --all

The component `playground` version  is not installed; downloading from repository.
download https://tiup-mirrors.pingcap.com/playground-v1.11.1-linux-amd64.tar.gz 7.44 MiB / 7.44 MiB 100.00% 11.99 MiB/s
Starting component `playground`: /home/jin/.tiup/components/playground/v1.11.1/tiup-playground
Using the version v6.5.0 for version constraint "".

If you'd like to use a TiDB version other than v6.5.0, cancel and retry with the following arguments:
        Specify version manually:   tiup playground <version>
        Specify version range:      tiup playground ^5
        The nightly version:        tiup playground nightly

Playground Bootstrapping...
Start pd instance:v6.5.0
The component `pd` version v6.5.0 is not installed; downloading from repository.
download https://tiup-mirrors.pingcap.com/pd-v6.5.0-linux-amd64.tar.gz 45.20 MiB / 45.20 MiB 100.00% 9.84 MiB/s
Start tikv instance:v6.5.0
The component `tikv` version v6.5.0 is not installed; downloading from repository.
download https://tiup-mirrors.pingcap.com/tikv-v6.5.0-linux-amd64.tar.gz 250.45 MiB / 250.45 MiB 100.00% 7.85 MiB/s
Start tidb instance:v6.5.0
The component `tidb` version v6.5.0 is not installed; downloading from repository.
download https://tiup-mirrors.pingcap.com/tidb-v6.5.0-linux-amd64.tar.gz 63.14 MiB / 63.14 MiB 100.00% 9.50 MiB/s
Waiting for tidb instances ready
127.0.0.1:4000 ... Done
The component `prometheus` version v6.5.0 is not installed; downloading from repository.
download https://tiup-mirrors.pingcap.com/prometheus-v6.5.0-linux-amd64.tar.gz 92.26 MiB / 92.26 MiB 100.00% 9.67 MiB/s
download https://tiup-mirrors.pingcap.com/grafana-v6.5.0-linux-amd64.tar.gz 50.12 MiB / 50.12 MiB 100.00% 9.76 MiB/s
Start tiflash instance:v6.5.0
The component `tiflash` version v6.5.0 is not installed; downloading from repository.
download https://tiup-mirrors.pingcap.com/tiflash-v6.5.0-linux-amd64.tar.gz 194.36 MiB / 194.36 MiB 100.00% 9.60 MiB/s
Waiting for tiflash instances ready
127.0.0.1:3930 ... Done
CLUSTER START SUCCESSFULLY, Enjoy it ^-^
To connect TiDB: mysql --comments --host 127.0.0.1 --port 4000 -u root -p (no password)
To view the dashboard: http://127.0.0.1:2379/dashboard
PD client endpoints: [127.0.0.1:2379]
To view the Prometheus: http://127.0.0.1:9090
To view the Grafana: http://127.0.0.1:3000

Verifying the Installed TiDB Practice Environment

Logging into the Dashboard

Logging into MySQL Client

Use the MySQL client to log into TiDB and query the TiDB version:

jin@TABLET-PBTEB744:~$ mysql --comments --host 127.0.0.1 --port 4000 -u root -p
Enter password:
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 441
Server version: 5.7.25-TiDB-v6.5.0 TiDB Server (Apache License 2.0) Community Edition, MySQL 5.7 compatible

Copyright (c) 2000, 2022, Oracle and/or its affiliates.

Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

mysql>
mysql>
mysql> select tidb_version();
+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| tidb_version()

       |
+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| Release Version: v6.5.0
Edition: Community
Git Commit Hash: 706c3fa3c526cdba5b3e9f066b1a568fb96c56e3
Git Branch: heads/refs/tags/v6.5.0
UTC Build Time: 2022-12-27 03:50:44
GoVersion: go1.19.3
Race Enabled: false
TiKV Min Version: 6.2.0-alpha
Check Table Before Drop: false
Store: tikv |
+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
1 row in set (0.00 sec)

mysql>

Summary

Execute wsl.exe --install -d Ubuntu-20.04 in Windows 11 PowerShell.

In Ubuntu bash, execute:

curl --proto '=https' --tlsv1.2 -sSf https://tiup-mirrors.pingcap.com/install.sh | sh
source /home/$USER/.bashrc
tiup playground

This is my first post, please be kind. The simplicity and ease of use of TiUP helped me get started quickly. I hope to share more articles in the future.

| username: tomxu | Original post link

Come and learn