sample my.cnf format for Azure database for mysql

Fiyin 1 Reputation point
2021-06-28T22:57:40.677+00:00

Is there a sample document that shows how to configure the user parameter in the .my.cnf file? I can't get this to work

[client]
host=cluster-1234.mysql.database.azure.com
user=adm@cluster-1234

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

6 answers

Sort by: Most helpful
  1. Oury Ba-MSFT 16,081 Reputation points Microsoft Employee
    2021-06-29T15:42:12.027+00:00

    Hi @Fiyin Thank you for posting your question.

    This is not supported. Could you please tell us what you are trying to achieve and we can provide a better suggestion.

    Regards,
    Oury

    0 comments No comments

  2. Fiyin 1 Reputation point
    2021-06-29T16:32:54.81+00:00

    Hi @Oury Ba-MSFT ,

    The .my.cnf file allows username and password to be passed to scripts without having to specify the username and password in every script which allows the password or username to be changed in one location without having to change it in multiple scripts. Also, it allows our admins to connect to mysql on the commandline without having to specify a user and password everytime especially when troubleshooting issues where time is of the essence and the admin needs to log in and out of the database multiple times.

    Regards,
    Fiyin

    0 comments No comments

  3. Fiyin 1 Reputation point
    2021-06-29T16:33:57.183+00:00

    I also know there are some tools that look for the my.cnf file to read connection info to avoid mulitple prompts for the user or password.

    0 comments No comments

  4. Oury Ba-MSFT 16,081 Reputation points Microsoft Employee
    2021-06-29T23:20:38.067+00:00

    Hello @Fiyin you can use Azure Active directory to achieve this goal and no need to update my.cnf as we are providing this feature out of the box for our customers.
    Use Azure Active Directory - Azure Database for MySQL | Microsoft Learn

    Regards,
    Oury

    0 comments No comments

  5. Fiyin 1 Reputation point
    2021-06-30T03:59:41.523+00:00

    Thanks for the update @Oury Ba-MSFT , is there an article that shows how to connect to Azure Active directory from a script in cron to obtain the credentials? A scheduled job can't do this part of the document

    Step 1: Authenticate with Azure AD
    Start by authenticating with Azure AD using the Azure CLI tool. This step is not required in Azure Cloud Shell.

    Copy
    az login
    The command will launch a browser window to the Azure AD authentication page. It requires you to give your Azure AD user ID and the password.