Why I can connect to Azure Database for MySQL - Single Server from Python locally without password(access token)?

Makoto Oda 291 Reputation points
2022-12-21T04:10:12.863+00:00

This question is related to this question.

I refered this article.

I became to be able to get access token by changing from https://ossrdbms-aad.database.windows.net to https://ossrdbms-aad.database.windows.net/.default.

However, I can connect to Azure Database for MySQL - Single Server from Python locally without password(access token).

My sample code is as follows:

When I make config["password"] = access_token.token enable, I got the error `mysql.connector.errors.ProgrammingError: 1045 (28000): Access denied for user '

Azure Database for MySQL
Azure Database for MySQL
An Azure managed MySQL database service for app development and deployment.
721 questions
{count} votes

Accepted answer
  1. GeethaThatipatri-MSFT 27,722 Reputation points Microsoft Employee
    2022-12-22T03:13:28.09+00:00

    @Makoto Oda Thanks for the ask and using the Microsoft Q&A platform.
    This requires more troubleshooting to isolate the issue, as the error is generic. General reasons for 1045 is outlined in the blog here

    1. Can you connect to MySQL using AAD authentication from client tools like mysql client, workbench etc..
    2. You should be looking at how the host name and user is specified (For single uername@keyman @<servername> is required) ?
    3. If you are receiving the token, then dump that token , Connection object and use client tools like workbench or ADS to connect to the server using the token.
    4. Are the firewall rules in place ?

    I hope this information helps to fix your problem.

    Regards
    Geetha


1 additional answer

Sort by: Most helpful
  1. Makoto Oda 291 Reputation points
    2023-01-20T00:10:59.18+00:00

    @GeethaThatipatri-MSFT

    I apologise that I wasted your time.

    The truth is revealed.

    Our DBA made a mistake.

    The DBA created db users as DB-Native-User not as AD-User.

    And, passwords are empty.

    So we did not need a password to connect Azure Database for MySQL.