How to Use Commands to Delete a Specific Key's Data in TiKV

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

Original topic: 如何使用 命令 删除 tikv中某个key的数据

| username: tikv-lu

TiKV cluster version v5.0.1

| username: Jellybean | Original post link

The recommended approach is to write SQL to directly drop the database at the TiDB level, rather than touching the physical disk files of TiKV.

| username: TIDB-Learner | Original post link

:100: :face_with_peeking_eye: Look at the deployment topology file, directly rm -rf, stay calm and composed.

| username: 林夕一指 | Original post link

tiup cluster clean, all in one step

| username: TiDBer_jYQINSnf | Original post link

It depends on your needs. If you don’t need the cluster anymore, just delete the directory. If you still want the cluster and want to completely restore it, just clear the directories of TiKV and PD, and restart it. It will automatically reinitialize, and even the passwords will be gone.

| username: zhanggame1 | Original post link

tiup cluster clean

| username: YuchongXU | Original post link

tiup cluster clean

| username: zhaokede | Original post link

Can’t synchronous deletion be used?

| username: vincentLi | Original post link

Decode the primary key ID from the key value, and then delete from it.

| username: vincentLi | Original post link

Here is a link to an additional decoding method:
TiDB Specific Functions | PingCAP Documentation Center

| username: lemonade010 | Original post link

Retrieving data through the key and then deleting the data by directly deleting the key is too risky.

| username: lemonade010 | Original post link

You can backtrack through this link: 专栏 - tidb中的key和MVCC value解析 | TiDB 社区

| username: 我是吉米哥 | Original post link

Yes, it is possible.

| username: tikv-lu | Original post link

I only used the TiKV cluster, without using TiDB.

| username: Defined2014 | Original post link

Use client-go to write code for deletion.

| username: yulei7633 | Original post link

Do not delete physical files, use SQL statements to delete.

| username: 有猫万事足 | Original post link

There are clients in so many languages that can delete. There is always one that suits you.

If it doesn’t work, use Python to make one. Looking at the example, it only takes a few lines of code to write.

| username: 表渣渣渣 | Original post link

Bullfrog, bullfrog

| username: 表渣渣渣 | Original post link

The TiKV client is divided into two, one is tikvclient and the other is rawclient. The tikvclient does not provide a delete API, while the rawclient does provide a delete API. However, I still haven’t figured out what the rawclient key is all about.

| username: 濱崎悟空 | Original post link

Please provide the Chinese text you would like translated into English.