When I am trying to import a .sql file which is stored in GCS , I am getting attached message from console related to super privileges, even import is failing like below
gcloud sql import sql XXXXXXXa gs://beta-db-dumps/sssc_0224.sql \ 1 ↵ 10008 14:42:11
--database=mysql \
--project=XXXXXXXa
Data from [gs://beta-db-dumps/sssc_0224.sql] will be imported to [XXXXXXXaXXXXXXXa-instance].
Do you want to continue (Y/n)? Y
Importing data into Cloud SQL instance...failed.
ERROR: (gcloud.sql.import.sql) [ERROR_RDBMS] error:
exit status 1
stderr:
ERROR 1227 (42000) at line 14: Access denied; you need (at least one of) the SUPER privilege(s) for this operation
Your SQL Script is failing because your .sql file (specifically at line 14) contains commands requiring SUPER privileges, which are restricted in Cloud SQL for security and stability.
To fix this:
Edit your .sql file (sssc_0224.sql):
Examine line 14. It likely contains a statement like DEFINER=…, SET @@GLOBAL…, or other commands needing high privileges.
Remove or modify these problematic statements. For DEFINER clauses, you can often remove them entirely or change them to DEFINER=CURRENT_USER.
Understood. Trying to edit a large SQL Dump script can be impractical. The best approach is to address this during the export process.
Use mysqldump with the --skip-definer flag. This prevents DEFINER clauses from being included in the dump file for routines, views, triggers, and events.
If your mysqldump version lacks --skip-definer, you can try to pipe the output through sed.
# Example sed command (test and adjust as needed):
mysqldump [other_options_here] ... | sed -E 's/\sDEFINER=`[^`]+`@`[^`]+`//g' | sed -E 's/\sSQL SECURITY DEFINER//g' > cleaned_dump.sql