When importing a MySQL database, you may encounter the error "1418 (HY000) at line 10185: This function has none of DETERMINISTIC, NO SQL, or READS SQL DATA in its declaration and binary logging is enabled (you might want to use the less safe log_bin_trust_function_creators variable)." This error occurs when you have not specified the deterministic nature of a function within the database.
To resolve this error, you can use one of two methods:
Method 1: Temporarily Disable Binary Logging
SET GLOBAL log_bin_trust_function_creators = 1;
Method 2: Configure the mysql.ini File
log_bin_trust_function_creators = 1;
By setting this value to 1, you are relaxing the checking for non-deterministic functions. This option should be used with caution as it can potentially compromise the integrity of your data.
Understanding Deterministic Functions
To avoid this error in the future, a better approach is to use deterministic declarations for stored functions. These declarations inform MySQL whether the function always produces the same result for the same input parameters. Here are the different deterministic declarations:
DETERMINISTIC:
NOT DETERMINISTIC:
READS SQL DATA:
NO SQL:
CONTAINS SQL:
Choosing the Correct Declaration
Selecting the correct declaration for a function depends on its behavior. If the function's output depends on factors external to the database, such as the current time or a random number generator, it should be declared as NOT DETERMINISTIC. If the function only reads data, it can be declared as READS SQL DATA. If the function does not contain any SQL statements, it can be declared as NO SQL.
Disclaimer: All resources provided are partly from the Internet. If there is any infringement of your copyright or other rights and interests, please explain the detailed reasons and provide proof of copyright or rights and interests and then send it to the email: [email protected] We will handle it for you as soon as possible.
Copyright© 2022 湘ICP备2022001581号-3