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
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
Finding Your Credentials
For TiDB Cloud
Log in to TiDB Cloud
Navigate to your cluster
Click the Connect button
Select your connection method and copy the connection details:
Host: The gateway hostname shown in the connection string
Port: Usually
4000Username: Your TiDB Cloud user
For the password, use the password you set when creating the cluster user
Step 1: Access TiDB Cloud Console
Log in to TiDB Cloud and select your cluster from the dashboard.
Step 2: Get Connection Details
Click the Connect button on your cluster
Choose General connection type
Copy the Host and Port from the connection string
Step 3: Create or Retrieve User Credentials
If you need to create a new user:
Go to SQL Editor in your cluster
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
Open the Memex Hub from the sidebar
Click on the Connectors tab
Find and click the TiDB card
Enter your Host, Port (4000), Database, Username, and Password
Give your connection a memorable name (e.g., "Production TiDB")
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:
Avoid using administrative accounts for application connections. Always follow the principle of least privilege.
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?