TiDB

Connect your TiDB distributed SQL databases to Memex for AI-powered analytics.

What is TiDB?

TiDB is an open-source, distributed SQL database that provides horizontal scalability, strong consistency, and high availability. It's MySQL-compatible, meaning you can use familiar MySQL syntax and tools. TiDB is commonly used for hybrid transactional and analytical processing (HTAP) workloads. Once connected, Memex can query your TiDB databases, explore schemas, and help you analyze your data through natural conversation.

What You'll Need

Credential
Description
Example

Host

TiDB cluster hostname

gateway01.us-east-1.prod.aws.tidbcloud.com

Port

TiDB server port

4000 (default)

Database

Name of the database

myapp

Username

TiDB username

app_user

Password

TiDB password

Your secure password

circle-info

TiDB uses port 4000 by default, not 3306 like standard MySQL. Make sure to use the correct port.

Finding Your Credentials

For TiDB Cloud

  1. Navigate to your cluster

  2. Click the Connect button

  3. Select your connection method and copy the connection details:

    • Host: The gateway hostname shown in the connection string

    • Port: Usually 4000

    • Username: Your TiDB Cloud user

  4. For the password, use the password you set when creating the cluster user

Step 1: Access TiDB Cloud Console

Log in to TiDB Cloudarrow-up-right and select your cluster from the dashboard.

Step 2: Get Connection Details

  1. Click the Connect button on your cluster

  2. Choose General connection type

  3. Copy the Host and Port from the connection string

Step 3: Create or Retrieve User Credentials

If you need to create a new user:

  1. Go to SQL Editor in your cluster

  2. Create a read-only user:

For Self-Hosted TiDB

Contact your database administrator to obtain:

  • The TiDB server hostname or IP address

  • The port number (default is 4000)

  • The database name

  • A username and password with appropriate permissions

Connecting to Memex

  1. Open the Memex Hub from the sidebar

  2. Click on the Connectors tab

  3. Find and click the TiDB card

  4. Enter your Host, Port (4000), Database, Username, and Password

  5. Give your connection a memorable name (e.g., "Production TiDB")

  6. Click Add Connection

Verifying Your Connection

Once connected, try asking Memex:

You should see a list of tables in your database.

Using Your Connection

Here are some examples of what you can ask:

Security Considerations

MySQL Compatibility

Since TiDB is MySQL-compatible, security practices are similar to MySQL:

  • Create dedicated users for Memex with read-only access

  • Use strong, unique passwords

  • Grant only SELECT permissions on required databases

User Permissions

Create a read-only user for Memex:

circle-exclamation

Network Security

For TiDB Cloud:

  • Traffic is encrypted with TLS by default

  • Configure IP access lists to restrict connections

  • Consider using private endpoints for production workloads

For self-hosted TiDB:

  • Enable TLS for encrypted connections

  • Configure firewall rules to restrict access

  • Use network segmentation to isolate database traffic

Troubleshooting

Connection Refused

  • Verify the hostname and port are correct

  • Remember TiDB uses port 4000, not 3306

  • For TiDB Cloud, ensure your IP address is in the allowed list

  • Check that the cluster is running and healthy

Authentication Failed

  • Double-check your username and password

  • Verify the user exists and has the correct password

  • Ensure the user has permission to connect from your location

  • Check if the user is locked or disabled

Database Not Found

  • Verify the database name is spelled correctly

  • Ensure the database exists on the cluster

  • Check that the user has permission to access the database

Slow Queries

  • TiDB Cloud Serverless may have cold start latency on first query

  • For large result sets, add LIMIT clauses to your queries

  • Check cluster resource utilization in TiDB Cloud dashboard

SSL/TLS Connection Issues

  • TiDB Cloud requires TLS connections

  • Ensure your client supports the required TLS version

  • Check if CA certificates need to be configured

Learn More

Last updated

Was this helpful?