Connecting to an Azure Database for MySQL server with Azure Client Shell

In a previous post at https://jaimemontoya.com/blog/2023/12/17/11/41/, I explained the process I followed for provisioning Azure relational database services to create a MySQL database resource.

Instead of downloading a MySQL client tool, I connected by using Azure Cloud Shell within the Azure portal.

I started by creating a new Azure Database for MySQL Flexible server with the following configurations:

New Azure Database for MySQL Flexible server

I made a note of my server name, server admin login name, and password for my newly created server from the Overview section of my server. I clicked Connect to open Azure Cloud Shell in the portal:

Server name ad admin login

I clicked Yes to allow public access from Azure Services within Azure to my server:

Allow public access from Azure Services

I connected to the server successfully with my credentials:

Successful connection to MySQL database
Requesting a Cloud Shell.Succeeded. 
Connecting terminal...

Welcome to Azure Cloud Shell

Type "az" to use Azure CLI
Type "help" to learn about Cloud Shell

wget --trust-server-names --no-check-certificate "https://go.microsoft.com/fwlink/?linkid=2157444"
--2024-01-12 07:27:42--  https://go.microsoft.com/fwlink/?linkid=2157444
Resolving go.microsoft.com... 23.40.70.176, 2600:1404:6400:88d::2c1a, 2600:1404:6400:895::2c1a
Connecting to go.microsoft.com|23.40.70.176|:443... connected.
HTTP request sent, awaiting response... 302 Moved Temporarily
Location: https://dl.cacerts.digicert.com/DigiCertGlobalRootCA.crt.pem [following]
--2024-01-12 07:27:42--  https://dl.cacerts.digicert.com/DigiCertGlobalRootCA.crt.pem
Resolving dl.cacerts.digicert.com... 192.229.211.108
Connecting to dl.cacerts.digicert.com|192.229.211.108|:443... connected.
HTTP request sent, awaiting response... 200 OK
Length: 1338 (1.3K) [application/x-pem-file]
Saving to: ‘DigiCertGlobalRootCA.crt.pem’

DigiCertGlobalRootCA.crt.pem                                100%[========================================================================================================================================>]   1.31K  --.-KB/s    in 0s      

2024-01-12 07:27:42 (38.4 MB/s) - ‘DigiCertGlobalRootCA.crt.pem’ saved [1338/1338]

jaime [ ~ ]$ mysql -h jaimemontoya.mysql.database.azure.com -u jaimemontoya -p "--ssl-ca=DigiCertGlobalRootCA.crt.pem"
Enter password: jaime [ ~ ]$ wget --trust-server-names --no-check-certificate "https://go.microsoft.com/fwlink/?linkid=2157444"
--2024-01-12 07:27:42--  https://go.microsoft.com/fwlink/?linkid=2157444
Resolving go.microsoft.com... 23.40.70.176, 2600:1404:6400:88d::2c1a, 2600:1404:6400:895::2c1a
Connecting to go.microsoft.com|23.40.70.176|:443... connected.
HTTP request sent, awaiting response... 302 Moved Temporarily
Location: https://dl.cacerts.digicert.com/DigiCertGlobalRootCA.crt.pem [following]
--2024-01-12 07:27:42--  https://dl.cacerts.digicert.com/DigiCertGlobalRootCA.crt.pem
Resolving dl.cacerts.digicert.com... 192.229.211.108
Connecting to dl.cacerts.digicert.com|192.229.211.108|:443... connected.
HTTP request sent, awaiting response... 200 OK
Length: 1338 (1.3K) [application/x-pem-file]
Saving to: ‘DigiCertGlobalRootCA.crt.pem’

DigiCertGlobalRootCA.crt.pem                                100%[========================================================================================================================================>]   1.31K  --.-KB/s    in 0s      

2024-01-12 07:27:42 (38.4 MB/s) - ‘DigiCertGlobalRootCA.crt.pem’ saved [1338/1338]

jaime [ ~ ]$ mysql -h jaimemontoya.mysql.database.azure.com -u jaimemontoya -p "--ssl-ca=DigiCertGlobalRootCA.crt.pem"
Enter password: 
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 13
Server version: 8.0.34 Source distribution

Copyright (c) 2000, 2023, Oracle and/or its affiliates.

Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

mysql> 
Published: 6:49 AM GMT · Jan 12, 2024