This function has none of DETEMINISTIC,NO SQL錯誤解決辦法
在MySQL中建立function的時候出現了"ERROR 1418 (HY000): 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)"的錯誤資訊。如下圖所示:
出現這個錯誤的原因是:
我們開啟了bin-log日誌(與MySQL的主從複製有關),slave會從master複製資料,而一些操作,比如function所得的結構在master和slave上的可能不同,所以存在潛在的安全隱患。因此預設情況下會組織function的建立。
解決這個問題有兩種辦法:
1、將Mysql Server的“log_bin_trust_function_creators”引數設定為ON,這樣一來開啟了log-bin的MySQL Server便可以隨意建立function。這裡存在潛在的資料安全問題,除非明確的知道建立function在master和slave上的行為完全一致。
我們可以通過命令列來設定該引數,如下所示
mysql> show variables like 'log_bin_trust_function_creators';
+---------------------------------+-------+
| Variable_name | Value |
+---------------------------------+-------+
| log_bin_trust_function_creators | OFF |
+---------------------------------+-------+
1 row in set (0.00 sec)
mysql> set global log_bin_trust_function_creators=1;
Query OK, 0 rows affected (0.00 sec)
mysql> show variables like 'log_bin_trust_function_creators';
+---------------------------------+-------+
| Variable_name | Value |
+---------------------------------+-------+
| log_bin_trust_function_creators | ON |
+---------------------------------+-------+
1 row in set (0.00 sec)
注:這種方式重啟MySQL服務後設定就會失效,如果想要永久生效,需要在MySQL的配置檔案中顯示配置。另外,如果再mster上建立函式,想通過主從複製的方式將函式複製到slsave上則也需在開啟了log-bin的slave中設定上述變數為ON(變數的設定不會從master複製到slave上,這點需要注意),否則主從複製會報錯。
2、明確指定我們的函式型別
1)、DETERMINISTIC 不確定的
2)、NO SQL 沒有sql語句,不會修改資料
3)、READS SQL DATA 只是讀取資料,當然也不會修改資料
這樣一來相當於明確的告知MySQL Server這個函式不會修改資料,因此可以在開啟了log-bin的伺服器上安全的建立並被複制到開啟了log-bin的salve上。
相關文章
- This function has none of DETERMINISTIC, NO SQL, or READS SQL DATA in its de 錯誤解決辦法FunctionNoneSQL
- Myeclipse 錯誤An internal error has occurred 解決辦法EclipseError
- 【MySQL】ERROR 1418 This function has none of DETERMINISTIC, NO SQL, ...MySqlErrorFunctionNone
- ERROR 1418 (HY000): This function has none of DETERMINISTIC, NO SQL,ErrorFunctionNoneSQL
- SAP錯誤提示解決辦法
- dns錯誤怎麼辦 dns錯誤的解決辦法DNS
- 連線oracle錯誤解決辦法Oracle
- nginxFastCGI錯誤Primaryscriptunknown解決辦法NginxAST
- Unable to locate package錯誤解決辦法Package
- oracle 1455 錯誤解決辦法Oracle
- 畢設之錯誤解決辦法
- 執行 valet 提示 sudo 問題和 undefined function Valet\collect () 錯誤的解決辦法UndefinedFunction
- Idea編譯錯誤解決辦法Idea編譯
- PHP編譯錯誤及解決辦法PHP編譯
- scp出現錯誤的解決辦法
- samba一個錯誤的解決辦法!Samba
- ORA-29339錯誤解決辦法
- ORA-54013錯誤解決辦法
- Mybatis批量更新SQL報錯☞解決辦法MyBatisSQL
- 解決MySQL server has gone away錯誤的解決方案MySqlServerGo
- iOS路上遇到的錯誤及解決辦法iOS
- ubuntu下import matplotlib錯誤解決辦法UbuntuImport
- ORA-12705,錯誤的解決辦法
- OpenCV1.0編譯錯誤解決辦法OpenCV編譯
- Xamarin提示安裝包錯誤解決辦法
- ORA-32004錯誤解決辦法
- SPFILE引數修改錯誤的解決辦法
- ORA-12170錯誤的解決辦法
- ORA-01846錯誤解決辦法
- Python:Python3錯誤提示TypeError: slice indices must be integers or None or have an __index__ method解決辦法PythonErrorNoneIndex
- ORA-39006錯誤原因及解決辦法
- Git 錯誤:fatel: loose object ... is corrupt 解決辦法GitObject
- 開機checking file錯誤的解決辦法
- Python——Output not utf-8錯誤解決辦法Python
- VPN連線800錯誤的解決辦法(轉)
- CentOS 中yum命令執行錯誤解決辦法CentOS
- nginx FastCGI錯誤Primary script unknown解決辦法NginxAST
- ORA-16014錯誤解決辦法