Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can't create Trigger on MySql table within Google Cloud [duplicate]

CREATE TRIGGER trigger_LocationType_Insert
BEFORE UPDATE ON LocationType
FOR EACH ROW
SET NEW.NAME = ''

Returns this error:

[HY000][1419] You do not have the SUPER privilege and binary logging is enabled (you *might* want to use the less safe log_bin_trust_function_creators variable)

I know this is because even the root user "has all privileges except SUPER and FILE." https://cloud.google.com/sql/docs/mysql/users

And I think that if I could "Set log_bin_trust_function_creators to 1" then it would work (this user does have CREATE TRIGGER permission). However, I don't see how to do that in the Google Cloud SQL console or from a sql statement.

How do you create a TRIGGER then within this environment?

like image 356
Gary Avatar asked Nov 17 '17 21:11

Gary


People also ask

What Cannot have a trigger associated with it in MySQL table?

Since triggers execute as part of a transaction, the following statements are not allowed in a trigger: All create commands, including create database, create table, create index, create procedure, create default, create rule, create trigger, and create view.

Which feature of MySQL is unsupported in GCP?

Unsupported client program featuresmysqldump using the --tab option or options that are used with --tab . This is because the FILE privilege is not granted for instance users. All other mysqldump options are supported.

Does mysql5 7 support triggers?

Does MySQL 5.7 have statement-level or row-level triggers? In MySQL 5.7, all triggers are FOR EACH ROW ; that is, the trigger is activated for each row that is inserted, updated, or deleted. MySQL 5.7 does not support triggers using FOR EACH STATEMENT .


1 Answers

This page described how to change MySQL configuration options for a Google Cloud instance: https://cloud.google.com/sql/docs/mysql/flags

Select the instance to open its Instance Overview page.

The database flags that have been set are listed under the Database flags section.

You have to use their UI to change global variables, because you can't use SET GLOBAL without SUPER privilege.

The log_bin_trust_function_creators option is listed among the supported configuration options you can change in the UI on the page I linked to above.

To read more about this error, see https://dev.mysql.com/doc/refman/5.7/en/stored-programs-logging.html

like image 104
Bill Karwin Avatar answered Oct 01 '22 00:10

Bill Karwin