This is the generic syntax for MySQL Connection URL using the Connector/J driver:


1. Protocol

There are four possible protocols for a connection:

  • jdbc:mysql: is for ordinary and basic failover connections.
  • jdbc:mysql:loadbalance: is for configuring load balancing.
  • jdbc:mysql:replication: is for configuring a replication setup.
  • mysqlx: is for connections using the X Protocol.

2. Hosts

If it’s a single host, such as localhost, the hosts part is in the format host:port and the URL syntax is as simple as this:

  • host can be an IPv4 or an IPv6 host name string. When not specified, localhost will be used.
  • post can be an integer from 1 to 65535. The default port number for MySQL connection is 3306, and for a connection using the X Protocol is 33060. If not specified, the default port will be used.

You can specify user credentials in the URL:

For example:

jdbc:mysql://myuser:[email protected]:3306/db

When there’re multiple hosts, the hosts will be listed in a comma-separated list:


Then the URL syntax will be like this:


If you want to include user credentials and allow sharing by all hosts, put the list of hosts inside the square blankets:

jdbc:mysql://myuser:[email protected][myhost1:port1,myhost2:port2]/db

3. Database

This to specify the default database to be opened when connected to the server. If there’s no database specified, the connection is made with no default database.

4. Properties

A succession of global properties applying to all hosts, preceded by ? and written as key=value pairs separated by the symbol & 

For example:

jdbc:mysql://myuser:[email protected]:3306/db?key1=value1&key2=value2&key3=value3


jdbc:mysql://myuser:[email protected][myhost1:port1,myhost2:port2]/db?key1=value1&key2=value2&key3=value3

Need a good GUI tool for databases? TablePlus provides a native client that allows you to access and manage Oracle, MySQL, SQL Server, PostgreSQL, and many other databases simultaneously using an intuitive and powerful graphical interface.

Download TablePlus for Mac.

Not on Mac? Download TablePlus for Windows.

On Linux? Download TablePlus for Linux

Need a quick edit on the go? Download TablePlus for iOS

TablePlus in Dark mode