Skip to content
Guide · DataGrip

How to Connect DataGrip to MySQL

Connecting DataGrip to MySQL takes one data source: host, port, user, password and, optionally, a default schema. This guide follows the JetBrains documentation for DataGrip 2026.2, covers the MySQL-specific options (Unix socket, driver properties, SSL and SSH), and explains the MySQL errors behind most failed first connections.

Steps and facts checked 8 October 2026 against the vendor's official documentation. Versions covered: DataGrip 2026.2, MySQL 5.1 to 9.x (DataGrip's documented range), MySQL Connector/J 9.5.0 bundled. Next review due April 2027. Menus, shortcuts and prices change between releases; check the vendor's documentation for your version.
Short answer
  • 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.
How we know: Research-based: the steps and options were checked against the DataGrip documentation, the MySQL 8.4 Reference Manual and the MySQL Connector/J documentation on 8 October 2026. We have not made this connection for the guide; labels are quoted from JetBrains' documentation.

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

  1. Go to File | New | Data Source and select MySQL, or click New on the Database Explorer toolbar.
  2. On the General tab, choose a Connection type: default (host, port, database and URL), Unix Socket (a socket file path) or URL only.
  3. Enter the Host and Port (3306 by default).
  4. Under Authentication, choose User & Password or No auth, and enter the User and Password.
  5. Optionally enter a Database (schema) to use by default.
  6. Click Test Connection.
  7. Optionally, on the Schemas tab, select more schemas to introspect; only the default schema is loaded otherwise.
  8. 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.

MySQL JDBC URL format and example from the DataGrip documentation
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)/myDatabase

Driver 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 include DISABLED, PREFERRED (encrypt if the server supports it) and REQUIRED, with stricter certificate-verifying modes beyond that.
  • allowPublicKeyRetrieval: allows a handshake round trip to fetch the server's RSA public key. It defaults to false. 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.

Errors described in the MySQL 8.4 Reference Manual
ErrorWhat the MySQL manual says it meansWhat 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

Checked 8 October 2026.

How we research tool guides: our editorial method. CodeWithSQL earns nothing from the vendors mentioned.

Still choosing a SQL client?

Read the full reviews, or compare tools side by side.