0

I am trying to connect my CloudSQL(MySQL 8.0) database instance having private ip which in GCP using Automatic IAM database authentication and Cloud SQL Auth proxy Iam getting this error access denied for user when accessing db using Heidisql client

I am providing the steps which I have followed to configure this:-

1.Add this flag to the database instance cloudsql_iam_authentication = on

2.Add an IAM policy binding to a user or service account "Cloud SQL Instance User" , "Cloud SQL Client". This role allows users to authenticate into the cloudsql using their cloud identity.

3.Once the role is granted the next step is to add the user or group to the CloudSql instance as below :- Navigate to ‘Console → SQL → Select Instance → Users → Add user account→ Cloud IAM → Enter email address → Add

  1. Grant database privileges to the IAM user

  2. Connecting to the CloudSQL using IAM Database Authentication First we need to install the latest version Cloud SQL auth proxy binary, then authenticate to the Google Cloud IAM.

        $ gcloud auth login
    
        $ gcloud config set project xyz
    
        $ .\cloud_sql_proxy.exe -enable_iam_login -instances=xyz:us-central1:mysql-iam-test=tcp:3306
    

I am attaching image for reference:-

cloud sdk command

Actual error

1 Answer 1

1

To connect to a Cloud SQL instance using Cloud SQL Auth Proxy, you need to use -ip_address_types=PRIVATE flag. You can view more about using the Cloud SQL Auth proxy with private IP here.

3
  • tried this $ .\cloud_sql_proxy.exe -enable_iam_login -instances=xyz:us-central1:mysql-iam-test=tcp:3306 -ip_address_types=PRIVATE but no luck. Commented Dec 29, 2022 at 5:55
  • This doc says to use the email of the IAM user as the username in the client. cloud.google.com/sql/docs/mysql/…. I see that you are providing only 'satyam', can you please try using the email id Commented Dec 30, 2022 at 7:31
  • 1
    your 1st answer was correct it helped , actually I authenticated another user using cloud sdk and I was passing different user in heidi sql , it should same as the authenticated user. Commented Dec 30, 2022 at 11:03

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.