0
votes

I am trying to import data from a csv file to my cloud sql instance. I have managed to load the csv file into a bucket. I am following the instructions given in the below page.

https://cloud.google.com/sql/docs/mysql/import-export/importing

The five instruction are:

  1. Create a Cloud Storage bucket, if you haven't already.

  2. Upload the CSV file to your bucket.

  3. Provide your instance with read permissions to your bucket.

  4. Import the file using:

ACCESS_TOKEN="$(gcloud auth application-default print-access-token)" curl --header "Authorization: Bearer ${ACCESS_TOKEN}" \ --header 'Content-Type: application/json' \ --data '{"importContext": {"fileType": "CSV", "uri": "gs:///", "database": "", "csvImportOptions": {"table": ""}}}' \ -X POST \ https://www.googleapis.com/sql/v1beta4/projects/[PROJECT-ID]/instances/[INSTANCE_NAME]/import

  1. If you do not need to retain the permissions provided by the ACL you set previously, remove the ACL.

I am unable to understand what to do in step 3 which is "Provide your instance with read permissions to your bucket." How do I provide my instance which read permission?

Also in step 4, what is the significance of Access token and what does it do?

1
When asking a question, do not send us to another document to read. Put everything needed to understand and reproduce your problem in the question. It is OK to include the document link as a reference but your question should be self contained.John Hanley
Edited the question. Thanks for your suggestionilegolas

1 Answers

1
votes

Edit your cloud sql instance's permissions at web UI , and enable Storage Read/Write permissions.

Cloud API access scope