3.9 KiB
3.9 KiB
DataGrip / MySQL Client Setup
TiDB Connection Details
Your local TiDB instance is ready for DataGrip or any MySQL-compatible client!
Connection Settings
| Setting | Value |
|---|---|
| Host | 127.0.0.1 or localhost |
| Port | 4000 |
| User | root |
| Password | (leave empty) |
| Database | (optional, or specify your synced database) |
DataGrip Configuration
1. Create New Data Source
- Open DataGrip
- Click + (New) → Data Source → MySQL
- Enter connection details:
- Host:
127.0.0.1 - Port:
4000 - Authentication: User & Password
- User:
root - Password: (leave empty)
- Database:
your_database(or leave empty to see all databases)
- Host:
2. Driver Configuration
- DataGrip will automatically use the MySQL driver
- TiDB is MySQL protocol-compatible, so no special driver needed
- If prompted, download the MySQL JDBC driver
3. Test Connection
Click Test Connection to verify:
- ✅ Should show "Successful" if TiDB is running
- ❌ If failed, ensure TiDB is running:
docker ps | grep tidb
4. Advanced Settings (Optional)
URL Template:
jdbc:mysql://127.0.0.1:4000
Connection Properties (optional):
useSSL=false(for local development)serverTimezone=UTCallowPublicKeyRetrieval=true
Full URL example:
jdbc:mysql://127.0.0.1:4000?useSSL=false&serverTimezone=UTC
Other MySQL Clients
MySQL Command Line
mysql -h 127.0.0.1 -P 4000 -u root
MySQL Workbench
- Connection Method: Standard TCP/IP
- Hostname:
127.0.0.1 - Port:
4000 - Username:
root - Password: (leave empty)
DBeaver
- Database: MySQL
- Server Host:
127.0.0.1 - Port:
4000 - Username:
root - Password: (leave empty)
TablePlus
- Connection Type: MySQL
- Host:
127.0.0.1 - Port:
4000 - User:
root - Password: (leave empty)
Verifying Your Synced Data
Once connected, run these queries to check your synced data:
-- Show all databases
SHOW DATABASES;
-- Switch to your synced database
USE your_database;
-- Show tables
SHOW TABLES;
-- Check table data
SELECT * FROM table1 LIMIT 10;
-- Check table structure
DESCRIBE table1;
-- Show table row count
SELECT COUNT(*) FROM table1;
Troubleshooting
Connection Refused
# Check if TiDB is running
docker ps | grep tidb
# Check TiDB logs
docker logs tidb
# Restart if needed
docker compose restart tidb
Can't See Synced Data
# Check DM sync status
./status.sh
# Or manually:
docker exec dm-master /dmctl --master-addr=dm-master:8261 query-status test-to-local
Port Already in Use
If port 4000 is already taken, you can change it in docker-compose.yml:
services:
tidb:
ports:
- "14000:4000" # Change host port to 14000
Then connect to 127.0.0.1:14000 instead.
Quick Verification
After starting your environment and connecting with DataGrip:
-
Check if sync is working:
-- In DataGrip, run: SELECT DATABASE(); SHOW DATABASES LIKE 'your_database'; -
Compare record counts:
-- In DataGrip (local TiDB) SELECT COUNT(*) FROM your_database.table1; -- Compare with test environment to verify sync -
Check data freshness:
-- If your table has timestamps SELECT MAX(updated_at) FROM your_database.table1;
Tips for DataGrip
- Auto-sync schema: Right-click database → Synchronize to refresh
- Multiple connections: You can add both test and local TiDB for comparison
- Query console: Use separate consoles for different environments
- Data comparison: Use DataGrip's compare feature to verify sync accuracy
Security Note
⚠️ This setup uses no password for local development convenience. For production:
- Set a strong password for TiDB
- Enable SSL/TLS
- Use proper network isolation