Reputation: 2217
I try to dump my Cloud SQL instance database from my local computer.
I know I should use gcloud commands but in the project I will use it would be a real pain to rewrite all the mysqldump instructions.
I can connect to Cloud SQL via the MySQL client, but when I try to use mysqldump I get the following:
mysqldump --databases testdb -h 130.211.xxx.xxx -u root -p > testdump.sql
mysqldump: Got error: 1227: Access denied; you need (at least one of) the SUPER privilege(s) for this operation when using LOCK TABLES
And of course CloudSQL doesn't support SUPER privileges... :/
Does anyone know if there's a way around?
Upvotes: 3
Views: 1172
Reputation: 2978
Yes it accepts it, but you must first, use the cloud_sql_proxy, and have the right permissions. Also this is not in the documentation as of the moment, neither as a warning nor as an official method. Still using an intermediary bucket for dumps is not of my liking.
In Mac OS with latest mysqldump as of moment (posted of an example of the problems I encountered might vary with os and mysqldump version)
mysqldump --column_statistics=0 -h 127.0.0.1 -u <user> -p <db> --set-gtid-purged=OFF> <dumpFile>
// this is because I use the tcp connection sample for the cloud sql proxy
mysql -h 127.0.0.1 -u <user> -p -D <database> < DBs/mysqldump100519.sql
Upvotes: 2
Reputation: 160
According to their documentation, seems you have 2 options.
The first, which you do not like is to use a gcloud command.
The second, use RESTful API to access the service which is, under the hood, used by gcloud commands. You may use the same request from inside you code. Take a look here.
Upvotes: 1