20

When trying to connect to my MySQL server in Azure from mysql client, I get the following error, even though I am using the correct username and server name. How can I fix this?

The connection string may not be right. Please visit portal for references.

Shantanu
  • 2,871
  • 4
  • 24
  • 38

3 Answers3

31

When connecting to your server instance of Azure Database for MySQL, you are required to follow the <username@hostname> format , whether you are doing it from mysqlexe client or MySQL workbench. We recommend you get the complete connection string for your client from the Azure portal and use it when connecting to your MySQL server.

Read How to get Connection Information to understand more about how to connect to your MySQL server from various clients.

Shantanu
  • 2,871
  • 4
  • 24
  • 38
9

I have the same issue and it appears that this is related to the MySQL Shell. Not the classic mysql.exe command line tool. I try to connect to my MySQL Azure database from within the MySQL Shell as follows:

mysql-sql> \sql
mysql-sql> \connect -c myuser@myserver.mysql.database.azure.com
Creating a Classic Session to 'myuser@myserver.mysql.database.azure.com'
Enter password: *********
ERROR: 2001 (28000): The connection string may not be right. Please visit portal for references.
mysql-sql>

According to the Azure docs (as referenced above) one should give the username as "username@servername" but there is no way to specify this using the MySQL Shell.

Has anyone succeeded in connecting to an Azure MySQL db via the MySQL Shell?

I can add that I have tested the same connection info with the classic mysql.exe and the following works fine:

mysql.exe -u myuser@myserver -h myserver.mysql.database.azure.com -p

My guess is that the real issue is that the MySQL Shell cannot accept an at sign (@) in the username.

Yooakim
  • 1,717
  • 2
  • 13
  • 21
  • MS has not been very clear on this, this post clarified it. So thank you. To qualify what I meant about "not clear", here is my observation. Supposing that my account is; myuser@mytestsql.mysql.database.azure.com In most cases myuser@mytestsql in the user name field would work, for example in MySQL workbench.  login: myuse@mytestsql That works! But occasionally I need to completely qualify the user name with the fully qualified host e.g., login: myuser@mytestsql.mysql.database.azure.com  This was the case with the IntelliJ's built in MySQL client. – Manabu Tokunaga Aug 06 '19 at 20:42
5

It's working for me use username@hostname in the username section.

vikaskumawat80
  • 109
  • 2
  • 4