Search code examples
google-bigquerygcloudgoogle-cloud-sql

BigQuery couldn't connect to cloud SQL (MYSQL)


I am trying to connecto my bigquery instance to my db ([email protected]) hosted on Cloud SQL the issue that I have once that we changed the database on my externa connection we got the following error: Method not found or User or password are empty and I can't update user and password

enter image description here


Solution

  • You can try this:

    $ bq mk \
         --connection \
         --connection_type='CLOUD_SQL' \
         --properties='{"instanceId":"myproject:us-east1:mysqlinstance","database":"mydb","type":"MYSQL"}' \
         --connection_credential='{"username":"username", "password":"*****"}' \
         --project_id=myproject \
         --location=us \
         ext_cloud_sql
    

    Query:

    SELECT * FROM EXTERNAL_QUERY("myproject.us.ext_cloud_sql", "SELECT * FROM mydb.mytable;")