TiDB

TiDB Start Guide

Remember: We use the same driver extension to connect for both TiDB and MySQL, so some of the settings and documentation refer to mysql or MySQL.

1. Connections

Connection example:

{
  "name": "TiDB",
  "server": "localhost",
  "driver": "TiDB",
  "port": 4000,
  "database": "test",
  "username": "root",
  "askForPassword": false,
  "password": "",
  "connectionTimeout": 15
}

1.1 Specific Options

TiDB driver specific options can be passed using mysqlOptions settings.

{
  "name": "TiDB",
  "server": "gateway01.ap-southeast-1.prod.aws.tidbcloud.com",
  "driver": "TiDB",
  "port": 4000,
  "database": "test",
  "username": "GfKM8ds5z2m614G.root",
  "askForPassword": false,
  "password": "<your_password>",
  "connectionTimeout": 15,
  "mysqlOptions": {
    ... // options See section 2. mysqlOptions
  }
}

2. mysqlOptions

TiDB can NOT use the xprotocol, so please keep the mysqlOptions.authProtocol is default option.

Extra options can be used as defined in the connectors documentation.

See https://github.com/mysqljs/mysql#connection-options and https://github.com/mysqljs/mysql#pool-options

They will be passed to the pool constructor directly. See https://github.com/mtxr/vscode-sqltools/blob/master/packages/core/driver/mysql/index.ts .

Typical Connect Scenarios

1. TiDB Cloud Serverless Tier

TiDB Cloud Serverless Tier need to point the CA certificates.

{
  "name": "TiDB",
  "server": "gateway01.ap-southeast-1.prod.aws.tidbcloud.com",
  "driver": "TiDB",
  "port": 4000,
  "database": "test",
  "username": "GfKM8ds5z2m614G.root",
  "askForPassword": false,
  "password": "<your_password>",
  "connectionTimeout": 15,
  "mysqlOptions": {
    "authProtocol": "default",
    "enableSsl": "Enabled",
    "ssl": {
      "ca": "/etc/ssl/cert.pem"
    }
  }
}

You can read the TLS Connections to Serverless Tier document to get more information.

2. Local Default TiUP Playground Cluster

If you use the TiUP to create a playground cluster at your local device. You can use this config to connect:

{
  "name": "TiDB",
  "server": "localhost",
  "driver": "TiDB",
  "port": 4000,
  "database": "test",
  "username": "root",
  "askForPassword": false,
  "password": "",
  "connectionTimeout": 15
}

Connection Options

askForPasswordboolean

Ask for password at connection time instead of storing it as plaintext in your settings.

Typeboolean
Default Valuefalse
connectionTimeoutnumber

Connection timeout in seconds.

Typenumber
Default Value15
connectStringstring | null

Connect string. Support for Oracle, PostgreSQL and AWS Redshift.

Typestring or null
cqlOptionsobject | null

See https://docs.datastax.com/en/developer/nodejs-driver/4.1/api/type.ClientOptions/ for more details.

Typeobject or null
Default Value{}
databasestring

Database name.

Typestring
dialectstring

Connection Driver

Typestring
driverstring

Connection driver used for this connection.

Typestring
groupstring

Connection group name.

Typestring
mysqlOptionsobject | null

See https://vscode-sqltools.mteixeira.dev/en/drivers/my-sql#2-mysqloptions for more details.

Typeobject or null
Default Value{}
Object Properties
PropertyDescriptionType
authProtocolstring
  • xprotocol
  • default
sslboolean, object, string or null
namestring

Connection name.

Typestring
passwordstring | null

Connection password

Typestring or null
portnumber

Port for connection.

Typenumber
previewLimitnumber

Maximum number of records to return in table previews.

Typenumber
Default Value50
serverstring

Server address.

Typestring
Default Value127.0.0.1
socketPathstring

Path of socket file to connect using UNIX sockets. MySQL only for now.

Typestring
usernamestring

Connection username.

Typestring
variablesobject | null

Connection variables in a key/value pair format. Use this property with sqltools.queryParams.enableReplace to replace the variables without prompting.

Typeobject or null
Default Valuenull
Object Properties
PropertyDescriptionType
ads via Carbon Design and Development tips in your inbox. Every weekday. ads via Carbon
×