Support MySQL official URI connection format (mysql://...)
Currently, the Go MySQL driver only supports the following DSN format:
user:password@tcp(localhost:3306)/dbname?param1=value1.
However, MySQL’s official documentation
defines a URI-based connection string format that looks like this:
mysql://user:password@localhost:3306/dbname?param1=value1
It would be useful if the driver could support the official URI scheme in addition to the current DSN format, for consistency with MySQL clients and other language drivers.
This would allow Go applications to accept and use standard MySQL connection URIs (e.g. from environment variables or config files) without having to reformat them.
Can I work on this?
@methane @julienschmidt @arnehormann , If this needs to be done then can I work on this?
Of course, you can work on this. But whether to adopt it is another matter.
This is a breaking change for a lot of existing code. The first task will be to come up with a plan for everyone to migrate. After reviewing that plan, we will carefully and thoughtfully consider the pros and cons over time and decide whether to make the change.
@methane Got it, thanks for the clarification! I’ll start looking into this and draft some initial ideas, but I’ll definitely need your input along the way. It would be really helpful if you could also add your thoughts or suggestions.
One important thing to note here: this is not actually a "MySQL official URI connection format", nor is it a "standard". It's just an optional way to specify connection information for MySQL Shell (mysqlsh). As far as I know, no other "official" MySQL client programs from Oracle use this format so far, and nothing in MariaDB uses this format either.
Also in terms of the params, the ones supported by MySQL Shell inherently differ from what is supported by the Go driver. This may cause some confusion if implemented. Ditto for the way unix socket connections are specified in this scheme.
Edit to add: I'm partially mistaken above, I suppose one could correctly consider that URI format "official" based on its support in all the Oracle-supplied Connector drivers. However personally I still think this isn't widespread enough to justify well:
- One motivator for Oracle creating this URI scheme was to support multiple protocols (classic
mysql://vs newer X protocolmysqlx://). Butgo-sql-driver/mysqldoes not support X protocol (see #478). Most third-party drivers (for any language) do not support it either. In any case, this motivation is not relevant here at this time. - Third-party drivers tend not to support this exact format, if they even support URIs at all.
- Aside from
mysqlsh, other official MySQL tools do not support URIs. For examplemysql,mysqldump,mysqladminall do not.