Connect to Azure Database with Mysql with mysql command line

Azure Mysql database in encrypted by default. The mysql connection fails when trying to login:

ERROR 9002 (28000): SSL connection is required. Please specify SSL options and retry.

Azure Database for MySQL supports connecting your Azure Database for MySQL server to client applications using Secure Sockets Layer (SSL). Enforcing SSL connections between your database server and your client applications helps protect against “man in the middle” attacks by encrypting the data stream between the server and your application.

Here is how to set up the connection to use SSL.

Download the certificate needed to communicate over SSL with your Azure Database for MySQL server from https://www.digicert.com/CACerts/BaltimoreCyberTrustRoot.crt.pem and save the certificate file to your local drive.

Connecting to server using the MySQL CLI over SSL


# mysql -h mydemoserver.mysql.database.azure.com -u Username@mydemoserver -p --ssl-ca=BaltimoreCyberTrustRoot.crt.pem

Leave a Comment