Skip to content

Support MySQL official URI connection format (mysql://...) #1736

Open

Description

@NamanMahor

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.

Activity

  1. ayushdoesdev commented on Oct 31, 2025

    @ayushdoesdev

    Can I work on this?

  2. ayushdoesdev commented on Oct 31, 2025

    @ayushdoesdev

    @methane @julienschmidt @arnehormann , If this needs to be done then can I work on this?

  3. methane commented on Oct 31, 2025

    @methane
    Member

    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.

  4. ayushdoesdev commented on Oct 31, 2025

    @ayushdoesdev

    @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.

  5. evanelias commented on Nov 25, 2025

    @evanelias
    Contributor

    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 protocol mysqlx://). But go-sql-driver/mysql does not support X protocol (see Add XAPI support #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 example mysql, mysqldump, mysqladmin all do not.
  6. saitocg commented on Feb 4, 2026

    @saitocg

    The URL scheme provided by Pulsar can be used as a reference for us.

    pulsar+tls://hostname:port/
    

    Here there will be default behavior (using TCP)

    mysql://user:password@localhost:3306/dbname?param1=value1 
    

    or specify the specific the transport protocol

    mysql+unix:///tmp/mysql.sock?charset=utf8mb4&parseTime=True&loc=Local
    
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions