Export from CloudSQL to CSV using select * into outfile

195 views
Skip to first unread message

Rajesh Golla

unread,
May 5, 2021, 9:11:43 AM5/5/21
to Google Cloud SQL discuss
Hi,

I am trying to generate csv file from cloudsql and place in cloud storage using below query:

select * INTO OUTFILE 'Cloudstorage_path/test.csv'         FIELDS TERMINATED BY ',' OPTIONALLY ENCLOSED BY '"'         LINES TERMINATED BY '\n' from Table limit 10

But I am getting below error:
Error Code: 1227. Access denied; you need (at least one of) the FILE privilege(s) for this operation

Please confirm whether we can use this approach to push data from cloudsql to cloud storage.

Elliott (Google Cloud Platform Support)

unread,
May 5, 2021, 11:26:49 AM5/5/21
to Google Cloud SQL discuss

Hello,


I understand that you would like to restore data from Cloud SQL to a Cloud Storage bucket but you are receiving Error 1227[1]. I was able to find an explanation indicating that this operation needs a Super User permission[2] that a managed Cloud SQL does not offer at this moment.

I was able to find this document[3], which describes how to generate a CSV from Cloud SQL as an alternative.

Would this be a sufficient workaround for you? I know this must be frustrating not to have technology not behaving as you wish. Please let us know your thoughts.

I would believe that the community may offer further advice or other ways to accomplish what you would like to do in another way in addition to the one I suggested.


[1] https://forums.mysql.com/read.php?10,674692,674692

[2] https://www.virtual-dba.com/blog/mysql-error-1227-access-denied/#:~:text=The%20reason%20MySQL%20throws%20error,the%20user%20importing%20the%20data.

[3] https://cloud.google.com/sql/docs/mysql/import-export/exporting

Rajesh Golla

unread,
May 6, 2021, 3:10:15 AM5/6/21
to Google Cloud SQL discuss
Hi Elliot,

Option3 is work around and I want to execute that select command using stored procedure and need to schedule it.

Anyways I got a approach with cloud function and cloud scheduler.

Thanks for the help

Biswanath Giri

unread,
May 7, 2021, 4:28:11 PM5/7/21
to google-cloud...@googlegroups.com
Hi all 

How to set alerts when cloud sql exports to gcp every 4 hours  if failed how to get notifications set for email if exporting not successfully done to gcs 

How to set alerts to solve the problem 

--
You received this message because you are subscribed to the Google Groups "Google Cloud SQL discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to google-cloud-sql-d...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/google-cloud-sql-discuss/2aa60a85-477d-49fa-88ae-7c34fe0d9becn%40googlegroups.com.
--
Regards
Biswanath Giri
Mob:9560016514

Felipe Bergallo Corral

unread,
May 12, 2021, 11:29:58 AM5/12/21
to Google Cloud SQL discuss
Heya, I'm guessing you didn't mean to reply to an existing conversation and meant to start a new one, nevertheless there is documentation for that:
Instructions on how to set up alerts can be found here; but I'm guessing your concern would be more to do with what to monitor specifically, and that depends on the error report given within the logs, which usually includes the metric that is used by the monitoring/alerting systems in the Google Operations Suite (which contains Cloud Monitoring and Cloud Alerts)

Is there any specific instruction that you require further clarification on?
Reply all
Reply to author
Forward
0 new messages