CentOS7 下调教mysql记实 之一
遷移數據庫時遇到錯誤:
Error Code: 1418. 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)
解釋:
默認情況下function的創建是禁止的。
原來是因為在主從復制的兩臺MySQL服務器中開啟了二進制日志選項log-bin,slave會從master復制數據,而一些操作,比如function所得的結果在master和slave上可能不同,所以存在潛在的安全隱患。因此,在默認情況下回阻止function的創建。
解決辦法:
在CentOS終端上運行:
# mysql -uroot -p你的密碼
MariaDB [(none)]> show variables like '%func%';
+---------------------------------+-------+
| Variable_name | Value |
+---------------------------------+-------+
| log_bin_trust_function_creators | OFF |
+---------------------------------+-------+
1 row in set (0.00 sec)
MariaDB [(none)]> set global log_bin_trust_function_creators=1;
Query OK, 0 rows affected (0.00 sec)
MariaDB [(none)]> show variables like '%func%';
+---------------------------------+-------+
| Variable_name | Value |
+---------------------------------+-------+
| log_bin_trust_function_creators | ON |
+---------------------------------+-------+
1 row in set (0.00 sec)
?
通過?set global log_bin_trust_function_creators=1; 的設置,在重啟后失效。永久辦法:
windows下my.ini[mysqld]加上log_bin_trust_function_creators=1 linux下/etc/my.cnf下my.cnf
[mysqld]加上log_bin_trust_function_creators=1
?
轉載于:https://www.cnblogs.com/dreamfine/p/6881751.html
總結
以上是生活随笔為你收集整理的CentOS7 下调教mysql记实 之一的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 不跟华为小米竞争!蔚来手机果真不一样:业
- 下一篇: 重装mysql出现无法start ser