Connect to TiDB with DBeaver

TiDB is a MySQL-compatible database, and DBeaver Community is a free cross-platform database tool for developers, database administrators, analysts, and everyone working with data.

In this tutorial, you can learn how to connect to your TiDB cluster using DBeaver Community.

DBeaver - 图1

Note

This tutorial is compatible with TiDB Serverless, TiDB Dedicated, and TiDB Self-Hosted.

Prerequisites

To complete this tutorial, you need:

If you don’t have a TiDB cluster, you can create one as follows:

If you don’t have a TiDB cluster, you can create one as follows:

Connect to TiDB

Connect to your TiDB cluster depending on the TiDB deployment option you’ve selected.

  • TiDB Serverless
  • TiDB Dedicated
  • TiDB Self-Hosted
  1. Navigate to the Clusters page, and then click the name of your target cluster to go to its overview page.

  2. Click Connect in the upper-right corner. A connection dialog is displayed.

  3. Ensure the configurations in the connection dialog match your operating environment.

    • Endpoint Type is set to Public
    • Branch is set to main
    • Connect With is set to DBeaver
    • Operating System matches your environment.
  4. Click Generate Password to create a random password.

    DBeaver - 图2

    Tip

    If you have created a password before, you can either use the original password or click Reset Password to generate a new one.

  5. Launch DBeaver and click New Database Connection in the upper-left corner. In the Connect to a database dialog, select TiDB from the list, and then click Next.

    Select TiDB as the database in DBeaver

  6. Copy the connection string from the TiDB Cloud connection dialog. In DBeaver, select URL for Connect by and paste the connection string into the URL field.

  7. In the Authentication (Database Native) section, enter your Username and Password. An example is as follows:

    Configure connection settings for TiDB Serverless

  8. Click Test Connection to validate the connection to the TiDB Serverless cluster.

    If the Download driver files dialog is displayed, click Download to get the driver files.

    Download driver files

    If the connection test is successful, the Connection test dialog is displayed as follows. Click OK to close it.

    Connection test result

  9. Click Finish to save the connection configuration.

  10. Navigate to the Clusters page, and then click the name of your target cluster to go to its overview page.

  11. Click Connect in the upper-right corner. A connection dialog is displayed.

  12. Click Allow Access from Anywhere, and then click Download CA cert to download the CA certificate.

    For more details about how to obtain the connection string, refer to TiDB Dedicated standard connection.

  13. Launch DBeaver and click New Database Connection in the upper-left corner. In the Connect to a database dialog, select TiDB from the list, and then click Next.

    Select TiDB as the database in DBeaver

  14. Copy and paste the appropriate connection string into the DBeaver connection panel. The mappings between DBeaver fields and TiDB Dedicated connection string are as follows:

    DBeaver fieldTiDB Dedicated connection string
    Server Host{host}
    Port{port}
    Username{user}
    Password{password}

    An example is as follows:

    Configure connection settings for TiDB Dedicated

  15. Click Test Connection to validate the connection to the TiDB Dedicated cluster.

    If the Download driver files dialog is displayed, click Download to get the driver files.

    Download driver files

    If the connection test is successful, the Connection test dialog is displayed as follows. Click OK to close it.

    Connection test result

  16. Click Finish to save the connection configuration.

  17. Launch DBeaver and click New Database Connection in the upper-left corner. In the Connect to a database dialog, select TiDB from the list, and then click Next.

    Select TiDB as the database in DBeaver

  18. Configure the following connection parameters:

    • Server Host: The IP address or domain name of your TiDB Self-Hosted cluster.
    • Port: The port number of your TiDB Self-Hosted cluster.
    • Username: The username to use to connect to your TiDB Self-Hosted cluster.
    • Password: The password of the username.

    An example is as follows:

    Configure connection settings for TiDB Self-Hosted

  19. Click Test Connection to validate the connection to the TiDB Self-Hosted cluster.

    If the Download driver files dialog is displayed, click Download to get the driver files.

    Download driver files

    If the connection test is successful, the Connection test dialog is displayed as follows. Click OK to close it.

    Connection test result

  20. Click Finish to save the connection configuration.

Next steps

Need help?

Ask questions on the Discord, or create a support ticket.