This is the generic syntax for MySQL Connection URL using the Connector/J driver:
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.
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:
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:
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.
A succession of global properties applying to all hosts, preceded by
? and written as
key=value pairs separated by the symbol
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.
Not on Mac? Download TablePlus for Windows.
On Linux? Download TablePlus for Linux
Need a quick edit on the go? Download TablePlus for iOS