The setup is such
VM with internal IP only -- NAT -- Cloud SQL for MySQL with external IP.
I researched and experimented and got this working. There could be other better ways to make the command work.
command sequence:
sudo apt update
sudo apt install wget
sudo apt install mariadb-client -y
cd /usr/bin
sudo wget https://dl.google.com/cloudsql/cloud_... -O cloud_sql_proxy
sudo chmod +x cloud_sql_proxy
cd /usr/lib/google-cloud-sdk/bin
sudo wget https://dl.google.com/cloudsql/cloud_... -O cloud_sql_proxy
sudo chmod +x cloud_sql_proxy
cd ~/
//run any gcloud command one to create the .config directory. In the video I have earlier run the gcloud command.
mkdir ~/.config/gcloud/legacy_credentials/
mkdir ~/.config/gcloud/legacy_credentials/{the compute sa email addr}
cd ~/.config/gcloud/legacy_credentials/{the compute sa email addr}
// upload service account key to the above directory. name it as adc.json
mv ~/adc.json .
gcloud beta sql connect iac-pub-mysql -u admin