Skip to content

Use Environment.UserName as the default user name #1161

Open
@bgrainger

Description

@bgrainger

This SO user (https://stackoverflow.com/questions/71742985/how-to-compose-a-connection-string-without-login-credentials-net-mysqlconnector) expects MySqlConnectionStringBuilder.UserID to default to the current Unix user when connecting via a Unix socket. That is how some other MySQL client libraries behave:

https://dev.mysql.com/doc/refman/8.0/en/user-names.html

On Unix, most MySQL clients by default try to log in using the current Unix user name as the MySQL user name, but that is for convenience only.

https://dev.mysql.com/doc/c-api/8.0/en/mysql-real-connect.html

The user argument contains the user's MySQL login ID. If user is NULL or the empty string "", the current user is assumed. Under Unix, this is the current login name.

The workaround is to manually set MySqlConnectionStringBuilder.UserID to Environment.UserName or a hard-coded user name.

Activity

bgrainger

bgrainger commented on Apr 12, 2022

@bgrainger
MemberAuthor

This could be a breaking change if there are some MySQL Servers that accept an empty username (although that seems unlikely). Still, to avoid unexpected behaviour, this implicit username could only be used for Unix socket connections (which is likely the most common scenario anyway).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

      Development

      No branches or pull requests

        Participants

        @bgrainger

        Issue actions

          Use `Environment.UserName` as the default user name · Issue #1161 · mysql-net/MySqlConnector