-
Notifications
You must be signed in to change notification settings - Fork 688
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: Developer Guide - GUI - VS Code SQLTools #14926
Merged
Merged
Changes from 6 commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
71f6794
feat: gui doc vscode sqltools
2bc6567
feat: toc
0dae5fd
Update dev-guide-gui-vscode-sqltools.md
shizn 238df45
Merge pull request #6 from shizn/patch-2
88d719f
Apply suggestions from code review
6f7d6d6
Merge branch 'master' into feat-gui-vscode-sqltools
dcfd94c
Apply suggestions from code review
dd6bd4a
delete: unused pics
e5fd5d1
Merge branch 'feat-gui-vscode-sqltools' of github.com:Icemap/docs int…
1106e3d
Update develop/dev-guide-gui-vscode-sqltools.md
cc27ba0
Apply suggestions from code review
Oreoxmt File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,191 @@ | ||
--- | ||
title: Connect to TiDB with Visual Studio Code | ||
summary: Learn how to connect to TiDB using Visual Studio Code or GitHub Codespaces. | ||
--- | ||
|
||
# Connect to TiDB with Visual Studio Code | ||
|
||
TiDB is a MySQL-compatible database, and [Visual Studio Code (VS Code)](https://code.visualstudio.com/) is a lightweight but powerful source code editor. This tutorial uses the [SQLTools](https://marketplace.visualstudio.com/items?itemName=mtxr.sqltools) extension which supports TiDB as an [official driver](https://marketplace.visualstudio.com/items?itemName=mtxr.sqltools-driver-mysql). | ||
|
||
In this tutorial, you can learn how to connect to your TiDB cluster using Visual Studio Code. | ||
|
||
> **Note:** | ||
> | ||
> - This tutorial is compatible with TiDB Serverless, TiDB Dedicated, and TiDB Self-Hosted. | ||
> - This tutorial also works with Visual Studio Code Remote Development environments, such as [GitHub Codespaces](https://github.com/features/codespaces), [Visual Studio Code Dev Containers](https://code.visualstudio.com/docs/devcontainers/containers), and [Visual Studio Code WSL](https://code.visualstudio.com/docs/remote/wsl). | ||
|
||
## Prerequisites | ||
|
||
To complete this tutorial, you need: | ||
|
||
- [Visual Studio Code](https://code.visualstudio.com/#alt-downloads) **1.72.0** or higher. | ||
Oreoxmt marked this conversation as resolved.
Show resolved
Hide resolved
|
||
- [SQLTools MySQL/MariaDB/TiDB](https://marketplace.visualstudio.com/items?itemName=mtxr.sqltools-driver-mysql) extension for Visual Studio Code. To install it, you can use one of the following methods: | ||
- Click [this link](vscode:extension/mtxr.sqltools-driver-mysql) to launch VS Code and install the extension directly. | ||
Icemap marked this conversation as resolved.
Show resolved
Hide resolved
|
||
- Navigate to [VS Code Marketplace](https://marketplace.visualstudio.com/items?itemName=mtxr.sqltools-driver-mysql) and click **Install**. | ||
- A TiDB cluster. | ||
|
||
<CustomContent platform="tidb"> | ||
|
||
**If you don't have a TiDB cluster, you can create one as follows:** | ||
|
||
- (Recommended) Follow [Creating a TiDB Serverless cluster](/develop/dev-guide-build-cluster-in-cloud.md) to create your own TiDB Cloud cluster. | ||
- Follow [Deploy a local test TiDB cluster](/quick-start-with-tidb.md#deploy-a-local-test-cluster) or [Deploy a production TiDB cluster](/production-deployment-using-tiup.md) to create a local cluster. | ||
|
||
</CustomContent> | ||
<CustomContent platform="tidb-cloud"> | ||
|
||
**If you don't have a TiDB cluster, you can create one as follows:** | ||
|
||
- (Recommended) Follow [Creating a TiDB Serverless cluster](/develop/dev-guide-build-cluster-in-cloud.md) to create your own TiDB Cloud cluster. | ||
- Follow [Deploy a local test TiDB cluster](https://docs.pingcap.com/tidb/stable/quick-start-with-tidb#deploy-a-local-test-cluster) or [Deploy a production TiDB cluster](https://docs.pingcap.com/tidb/stable/production-deployment-using-tiup) to create a local cluster. | ||
|
||
</CustomContent> | ||
|
||
## Connect to TiDB | ||
|
||
Connect to your TiDB cluster depending on the TiDB deployment option you've selected. | ||
Oreoxmt marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
<SimpleTab> | ||
<div label="TiDB Serverless"> | ||
|
||
1. Navigate to the [**Clusters**](https://tidbcloud.com/console/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` | ||
- **Connect With** is set to `General` | ||
Oreoxmt marked this conversation as resolved.
Show resolved
Hide resolved
|
||
- **Operating System** matches your environment. | ||
|
||
> **Tip:** | ||
> | ||
> If your VS Code is running against a remote development enviorment, select the remote OS from the list. For example, if you are using Windows Subsystem for Linux (WSL), switch to the corresponding Linux distribution. If you are using Github Codespaces, this doesn't matter. | ||
Icemap marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
4. Click **Create password** to create a random password. | ||
|
||
> **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. Go back to VS Code, click **Add New Connection**, and select **TiDB** type. | ||
Icemap marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
![VS Code sqltools add bew connection](/media/develop/vsc-sqltools-add-new-connection.jpg) | ||
Icemap marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
6. Fill in parameters in setting panal. | ||
Icemap marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
- Connection name: Please give a meanful name for this connection. | ||
- Connection group: (Optional) A meanful name for the group of this connection. And the connections which have the same group name will be gethered together. | ||
- Connect using: Please select **Server and Port**. | ||
- Server Address: The parameter `host` from TiDB Cloud connection dialog. | ||
- Port: The parameter `port` from TiDB Cloud connection dialog. | ||
- Database: The database that you want to connect. | ||
- Username: The parameter `user` from TiDB Cloud connection dialog. | ||
- Password mode: Please select **SQLTools Driver Credentials**. | ||
- In **MySQL driver specific options** scope: | ||
Icemap marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
- Authentication Protocol: Please select **default**. | ||
- SSL: Please select **Enabled**. TiDB Serverless requires a secure connection. In **SSL Options (node.TLSSocket)** scope: | ||
|
||
- Certificate Authority (CA) Certificate File: sername: The parameter `ssl_ca` from TiDB Cloud connection dialog. | ||
Icemap marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
> **Note:** | ||
> | ||
> If you are running on Windows or Github Codespaces, you can leave this blank. Default is to trust the well-known CAs curated by Mozilla. Learn more about [TiDB Serverless root certificate management](https://docs.pingcap.com/tidbcloud/secure-connections-to-serverless-clusters#root-certificate-management) | ||
Icemap marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
![VS Code sqltools serverless connection config](/media/develop/vsc-sqltools-connection-config-serverless.jpg) | ||
Icemap marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
7. Click **TEST CONNECTION**, then click **Allow** in the popupwindow. | ||
8. Enter `password` from TiDB Cloud. | ||
|
||
![VS Code sqltools serverless password](/media/develop/vsc-sqltools-password.jpg) | ||
Icemap marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
9. If you can see **Successfully connected!** text appared. Then click **SAVE CONNECTION**. | ||
Icemap marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
</div> | ||
<div label="TiDB Dedicated"> | ||
|
||
1. Navigate to the [**Clusters**](https://tidbcloud.com/console/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. Click **Allow Access from Anywhere**. | ||
|
||
For more details about how to obtain the connection string, refer to [TiDB Dedicated standard connection](https://docs.pingcap.com/tidbcloud/connect-via-standard-connection). | ||
|
||
4. Go back to VS Code, click **Add New Connection**, and select **TiDB** type. | ||
Icemap marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
![VS Code sqltools add bew connection](/media/develop/vsc-sqltools-add-new-connection.jpg) | ||
Icemap marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
5. Fill in parameters in setting panal. | ||
Icemap marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
- Connection name: Please give a meanful name for this connection. | ||
- Connection group: (Optional) A meanful name for the group of this connection. And the connections which have the same group name will be gethered together. | ||
- Connect using: Please select **Server and Port**. | ||
- Server Address: The parameter `host` from TiDB Cloud connection dialog. | ||
- Port: The parameter `port` from TiDB Cloud connection dialog. | ||
- Database: The database that you want to connect. | ||
- Username: The parameter `user` from TiDB Cloud connection dialog. | ||
- Password mode: Please select **SQLTools Driver Credentials**. | ||
- In **MySQL driver specific options** scope: | ||
Icemap marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
- Authentication Protocol: Please select **default**. | ||
- SSL: Please select **Disabled**. | ||
Icemap marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
![VS Code sqltools dedicated connection config](/media/develop/vsc-sqltools-connection-config-dedicated.jpg) | ||
Icemap marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
6. Click **TEST CONNECTION**, then click **Allow** in the popupwindow. | ||
7. Enter `password` from TiDB Cloud. | ||
Icemap marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
![VS Code sqltools dedicated password](/media/develop/vsc-sqltools-password.jpg) | ||
Icemap marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
8. If you can see **Successfully connected!** text appared. Then click **SAVE CONNECTION**. | ||
Icemap marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
</div> | ||
<div label="TiDB Self-Hosted"> | ||
|
||
1. Click **Add New Connection**, and select **TiDB** type. | ||
Icemap marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
![VS Code sqltools add bew connection](/media/develop/vsc-sqltools-add-new-connection.jpg) | ||
Icemap marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
2. Fill in parameters in setting panal. | ||
Icemap marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
- Connection name: Please give a meanful name for this connection. | ||
- Connection group: (Optional) A meanful name for the group of this connection. And the connections which have the same group name will be gethered together. | ||
- Connect using: Please select **Server and Port**. | ||
- Server Address: TiDB cluster host. | ||
- Port: TiDB cluster host. | ||
- Database: The database that you want to connect. | ||
- Username: TiDB cluster username. | ||
- Password mode: | ||
Icemap marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
- If the password is empty, please select **Use empty password**. | ||
- Otherwise, please select **SQLTools Driver Credentials**. | ||
Icemap marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
- In **MySQL driver specific options** scope: | ||
Icemap marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
- Authentication Protocol: Please select **default**. | ||
- SSL: Please select **Disabled**. | ||
Icemap marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
![VS Code sqltools self-hosted connection config](/media/develop/vsc-sqltools-connection-config-self-hosted.jpg) | ||
Icemap marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
3. Click **TEST CONNECTION**. | ||
4. (Optional) If the password is not empty, click **Allow** in the popupwindow, then enter the password from TiDB cluster. | ||
|
||
![VS Code sqltools self-hosted password](/media/develop/vsc-sqltools-password.jpg) | ||
Icemap marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
5. If you can see **Successfully connected!** text appared. Then click **SAVE CONNECTION**. | ||
Icemap marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
</div> | ||
</SimpleTab> | ||
|
||
## Next steps | ||
|
||
- Learn more usage of Visual Studio Code from [the documentation of Visual Studio Code](https://code.visualstudio.com/docs). | ||
- Learn more usage of VS Code SQLTools extension from [the documentation](https://marketplace.visualstudio.com/items?itemName=mtxr.sqltools) and [GitHub repository](https://github.com/mtxr/vscode-sqltools) of SQLTools. | ||
- Learn the best practices for TiDB application development with the chapters in the [Developer guide](/develop/dev-guide-overview.md), such as [Insert data](/develop/dev-guide-insert-data.md), [Update data](/develop/dev-guide-update-data.md), [Delete data](/develop/dev-guide-delete-data.md), [Single table reading](/develop/dev-guide-get-data-from-single-table.md), [Transactions](/develop/dev-guide-transaction-overview.md), and [SQL performance optimization](/develop/dev-guide-optimize-sql-overview.md). | ||
- Learn through the professional [TiDB developer courses](https://www.pingcap.com/education/) and earn [TiDB certifications](https://www.pingcap.com/education/certification/) after passing the exam. | ||
|
||
## Need help? | ||
|
||
Ask questions on the [Discord](https://discord.gg/vYU9h56kAX), or [create a support ticket](https://support.pingcap.com/). |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Icemap marked this conversation as resolved.
Show resolved
Hide resolved
|
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Icemap marked this conversation as resolved.
Show resolved
Hide resolved
|
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Icemap marked this conversation as resolved.
Show resolved
Hide resolved
|
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Preview: https://scaffold-git-preview-pingcapdocs14926-oreoxmt.vercel.app/tidb/dev/dev-guide-gui-vscode-sqltools