Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Create function on google mysql gives "SUPER privilege and binary logging is enabled" error

Trying to create functions on MySQL that runs on Google CloudSQL. These functions worked fine on another server (VPS- Godaddy).

Official documentation says that User Defined Functions are not supported, but I am trying to create a regular stored function and not a UDF.

Lookup Error - MySQL Database Error: 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)

Logged in using Toad

Username used TAdmin

Sample Function:

DELIMITER $$
DROP FUNCTION IF EXISTS `func_getEQId`$$
CREATE DEFINER=`TAdmin`@`%` FUNCTION `func_getEQId` (`pTopicId` INT(11))
RETURNS BIGINT(20)

READS SQL DATA DETERMINISTIC

BEGIN
DECLARE vQId bigint (20);

SELECT QId INTO vQId FROM quests WHERE... 

RETURN vQId;

END$$

Don't want to disable binary logging

like image 498
M J Avatar asked Jun 09 '16 06:06

M J


People also ask

How do I enable super privileges in MySQL?

To add super privileges to MySQL database, the following is the syntax. mysql> GRANT SUPER ON *. * TO user@'localhost' IDENTIFIED BY 'passwordName'; After executing the above query, do not forget to end it with the following command.

Do not have the Super privilege and binary logging is enabled?

The error arises when you try to import the function or trigger containing dangerous statements that make changes in the database. The error arises only if the binary logging option, which is required for the replication, is turned on for the MySQL server.

What is super privilege in MySQL?

SUPER can be used to terminate other sessions or change how the server operates. Privileges granted for the mysql system database itself can be used to change passwords and other access privilege information: Passwords are stored encrypted, so a malicious user cannot simply read them to know the plain text password.

What is binary log in MySQL?

The binary log contains “events” that describe database changes such as table creation operations or changes to table data. It also contains events for statements that potentially could have made changes (for example, a DELETE which matched no rows), unless row-based logging is used.


1 Answers

If using Cloud SQL, enable the log_bin_trust_function_creators by running:

gcloud sql instances patch [INSTANCE_NAME] --database-flags log_bin_trust_function_creators=on

More information in the Cloud SQL Documentation.

like image 79
gabidavila Avatar answered Oct 19 '22 08:10

gabidavila