How to Connect MySQL to DataGrip

Galaxy Glossary

How do I connect MySQL to DataGrip?

Connect MySQL to DataGrip by supplying JDBC URL, host, port, credentials, and testing the connection.

Sign up for the latest in SQL knowledge from the Galaxy Team!

Description

What prerequisites are needed?

Install DataGrip 2023.2+, have MySQL server running, and note the host, port (default 3306), user, and password. Download the MySQL JDBC driver if DataGrip doesn’t auto-resolve it.

How to add a new MySQL data source?

Open DataGrip → Database tool window → “+” → Data Source → MySQL. The “Data Sources & Drivers” dialog appears.

Which fields must I fill?

Enter Host, Port, User, Password, and Database.Optionally enable SSL or SSH tunnel under the “SSH/SSL” tab.

What JDBC URL should I use?

DataGrip auto-generates the URL. Custom format: jdbc:mysql://host:port/database?user=<user>&password=<pass>&serverTimezone=UTC. Paste it in the URL box when you need advanced parameters.

How to test and save the connection?

Click “Test Connection.” Green means success. Fix driver or firewall issues if red.Click “OK” to save.

How to run queries after connecting?

Right-click the new data source → “New” → “SQL Console.” Write queries like SELECT * FROM Customers LIMIT 10; and press ⌘↵/Ctrl+Enter to execute.

Best practices for stable connections?

Set “Keep-alive” interval under Advanced settings, use SSH tunnels for remote servers, store credentials in DataGrip’s password vault, and version-control your DataGrip project files.

.

Why How to Connect MySQL to DataGrip is important

How to Connect MySQL to DataGrip Example Usage


-- List most recent orders after connecting
SELECT o.id, c.name, o.total_amount
FROM Orders o
JOIN Customers c ON c.id = o.customer_id
ORDER BY o.order_date DESC
LIMIT 20;

How to Connect MySQL to DataGrip Syntax


jdbc:mysql://<HOST>:<PORT>/<DATABASE>?user=<USER>&password=<PASSWORD>&serverTimezone=UTC

# Example filled
jdbc:mysql://localhost:3306/ecommerce?user=reporter&password=StrongPass!&serverTimezone=UTC

Common Mistakes

Frequently Asked Questions (FAQs)

Do I need to install a separate MySQL client?

No. DataGrip bundles a console. You only need the MySQL JDBC driver, which DataGrip can download automatically.

Can I connect through SSL?

Yes. In the data-source dialog, open “SSH/SSL,” enable SSL, select “Verify CA,” and provide the CA certificate.

How do I share the connection settings?

Right-click the data source → “Database Tools” → “Copy Settings.” Share the .idea folder or use JetBrains Space to sync settings.

Want to learn about other SQL terms?

Trusted by top engineers on high-velocity teams
Aryeo Logo
Assort Health
Curri
Rubie
BauHealth Logo
Truvideo Logo