- Use File | New | Data Source | MySQL, enter host, port 3306, user and password, then click Test Connection.
- DataGrip documents support for MySQL 5.1 to 9.x and bundles MySQL Connector/J 9.5.0 from version 2026.2.
- Besides host and port, a MySQL data source can connect through a Unix socket file. Driver properties such as sslMode go on the Advanced tab.
- Errors 2002 and 2003 mean nothing answered on that socket or port; error 1045 means MySQL answered and rejected the user or password.
What a DataGrip MySQL connection needs
A DataGrip MySQL connection needs a running MySQL server, its host and port (3306 unless changed), and a MySQL account that is allowed to connect from your machine. MySQL accounts are tied to a host as well as a user name, so an account that works on the server itself may be refused from your laptop.
DataGrip documents support for MySQL 5.1 to 9.x. From DataGrip 2026.2 the MySQL Connector/J 9.5.0 driver is bundled, so there is normally nothing to download. MariaDB has its own data source type in DataGrip; choose it rather than MySQL when you connect to a MariaDB server.
Create the MySQL data source
- Go to File | New | Data Source and select MySQL, or click New on the Database Explorer toolbar.
- On the General tab, choose a Connection type: default (host, port, database and URL), Unix Socket (a socket file path) or URL only.
- Enter the Host and Port (3306 by default).
- Under Authentication, choose User & Password or No auth, and enter the User and Password.
- Optionally enter a Database (schema) to use by default.
- Click Test Connection.
- Optionally, on the Schemas tab, select more schemas to introspect; only the default schema is loaded otherwise.
- Click OK, then select the data source and press F4 to open a query console.
JetBrains' URL format for MySQL uses the long address=(...) form shown below. As with other engines, a URL only data source stores the URL, including any credentials in it, in plain text.
jdbc:mysql://address=(protocol=tcp)(host=<host_address>)(port=<port_number>)/<database_name>
jdbc:mysql://address=(protocol=tcp)(host=127.0.0.1)(port=3306)/myDatabaseDriver properties on the Advanced tab
The Advanced tab of the data source lists connection options that DataGrip passes to the JDBC driver as key and value pairs. Two Connector/J properties come up often with MySQL:
sslMode: Connector/J encrypts connections by default. The documented values includeDISABLED,PREFERRED(encrypt if the server supports it) andREQUIRED, with stricter certificate-verifying modes beyond that.allowPublicKeyRetrieval: allows a handshake round trip to fetch the server's RSA public key. It defaults tofalse. If a driver error mentions public key retrieval, this is the property involved; prefer SSL where you can.
SSL and SSH tunnel settings
Both live on the SSH/SSL tab. For SSL, select Use SSL, add the CA file (or use a truststore), add a client certificate and key only if the server requires them, and choose Require, Verify CA or Full Verification in Mode. JetBrains notes that with self-signed certificates the newest driver may reject the chain, and gives downgrading the MySQL connector as a temporary workaround.
For a server behind a bastion host, select Use SSH tunnel, click Add SSH configuration, and enter the SSH host, port, user name and an authentication type (Password, Key pair (OpenSSH or PuTTY), or OpenSSH config and authentication agent). The database host on the General tab is then resolved on the SSH server, so localhost means the SSH server itself. Remember that MySQL sees the connection as coming from the SSH server, which matters for the host part of the account.
Common MySQL connection errors in DataGrip
DataGrip's troubleshooting page suggests checking the host with ping and the port with telnet, confirming the driver version suits the server, and, on Windows, keeping the temp directory path free of non-ASCII characters.
| Error | What the MySQL manual says it means | What to check in DataGrip |
|---|---|---|
(2002) Can't connect to ... | No MySQL server is running, or the socket file name or TCP/IP port is wrong. | Host, port, and the socket path if you chose Unix Socket. |
(2003) Can't connect to MySQL server on 'server' (10061) | The network connection was refused. | That the server runs, accepts network connections and that a firewall is not blocking the port. |
ERROR 1045 (28000): Access denied for user ... | The server answered and rejected the account or password. | User and password, and whether the account is allowed from your host (or from the SSH server). |
Frequently asked questions
What is the default MySQL port in DataGrip?
3306. Change it if your server listens on a different port.
Can DataGrip connect to MySQL through a Unix socket?
Yes. Choose Unix Socket as the connection type and give the path to the socket file.
Which MySQL versions does DataGrip support?
The DataGrip documentation lists MySQL 5.1 to 9.x.
Why does DataGrip say access denied when the MySQL command line works?
MySQL accounts include a host. The command line on the server may connect as user@localhost, while DataGrip on another machine (or through an SSH tunnel) arrives from a different host that the account does not allow.
Where do I set Connector/J properties such as sslMode?
On the Advanced tab of the data source, which passes its key and value pairs to the JDBC driver.
Sources
- DataGrip documentation: MySQL
- DataGrip documentation: Configure SSH and SSL
- DataGrip documentation: Data Sources and Drivers dialog
- DataGrip documentation: Cannot connect to a database
- JetBrains: What's New in DataGrip 2026.2
- DataGrip documentation: MariaDB
- MySQL 8.4 Reference Manual: Can't connect to MySQL server
- MySQL 8.4 Reference Manual: Troubleshooting problems connecting to MySQL
- MySQL Connector/J: Security configuration properties
Checked 8 October 2026.
How we research tool guides: our editorial method. CodeWithSQL earns nothing from the vendors mentioned.