mysql 报错之创建自定义函数

I experienced this error while trying to alter one of my stored procedures remotely on a master server. After some research, I ended up getting information from “Binary Logging of Stored Programs“.

From MySQL Reference in verbatim:
When you create a stored function, you must declare either that it is deterministic or that it does not modify data. Otherwise, it may be unsafe for data recovery or replication.

By default, for a CREATE FUNCTION statement to be accepted, at least one of DETERMINISTIC, NO SQL, or READS SQL DATA must be specified explicitly. Otherwise an error occurs:

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)

Further reading helped me arrive to the conclusion to the cause of this error:

Cause:
The error arises if the binary logging option, which is required for the replication, is turned on for the MySQL server.

We can choose solutions listed below depending to our system requirements, for me, I opted on using the later.

  1. When creating or altering a stored function, you must declare either that it is deterministic or that it does not modify data. Otherwise, it may be unsafe for data recovery or replication.
  2. To relax the preceding conditions on function creation (that you must have the SUPER privilege and that a function must be declared deterministic or to not modify data), set the global log_bin_trust_function_creators system variable to 1. By default, this variable has a value of 0, but you can change it like this:

    mysql> SET GLOBAL log_bin_trust_function_creators = 1;

    You can also set this variable by using the –log-bin-trust-function-creators=1 option when starting the server.

MySQL Open Source Software Development

POSTED ON SUNDAY, NOVEMBER 11TH, 2012 AT 11:54 PM PRINT THIS ARTICLE EMAIL THIS ARTICLE

Next Article

Previous Article

ob·liv·i·on

noun \?-?bli-vē?n\
Reference : Merriam-Webster

  1. the fact or condition of forgetting or having forgotten; especially : the condition of being oblivious
  2. the condition or state of being forgotten or unknown

tH3 oBlivIOus

Aldwin Llacuna Galapon
IT Consultant / Software and Web Developer

Do not take life too seriously. You might not get out of it alive!

  • FACEBOOK
  • TWITTER

mysql 报错之创建自定义函数

时间: 2024-08-10 19:19:10

mysql 报错之创建自定义函数的相关文章

mysql创建自定义函数与存储过程

mysql创建自定义函数与存储过程 一 创建自定义函数 在使用mysql的过程中,mysql自带的函数可能不能完成我们的业务需求,这时就需要自定义函数,例如笔者在开发过程中遇到下面这个问题 mysql表结构如下 DROP TABLE IF EXISTS `test`; CREATE TABLE `test` ( `id` int(10) unsigned NOT NULL AUTO_INCREMENT, `pic` varchar(50) NOT NULL, `hashcode` varchar

Mysql 报错:#1067 - Invalid default value for 'update_time

由于 字段UPDATE_TIME 的字段类型是 timestamp ,默认值是:'0000-00-00 00:00:00' 即:`UPDATE_TIME` timestamp NOT NULL DEFAULT '0000-00-00 00:00:00' COMMENT '更新时间'; 在对这个表进行创建的时候,提示: #1067 - Invalid default value for 'update_time 原因: timestamp有效时间在:1970-01-01 00:00:00 到 20

连接mysql报错:error 2003 (hy000):can't connect to mysql server on 'localhost' (10061)

一.mysql 的bin目录下有个MySQLInstanceConfig.exe,运行就可以进行创建数据库实例,创建实例时也可以生成windows 服务,把服务设置成自动启动就可以了 二.安装在D盘的discuzz!打开后出现上述错误,请问应如何处理?winmysqladmin已经启动,但三色树上有一个小红点如果出现"ERROR 2003: Can't connect to MySQL server on 'localhost' (10061)",说明你的MySQL还没有启动.解决办法

PHP连接MySQL报错:SQLSTATE[HY000] [2002] Can't connect to local MySQL server through socket 'MySQL' (2)

如下所示,PHP连接MySQL报错: SQLSTATE[HY000] [2002] Can't connect to local MySQL server through socket 'MySQL' (2) 测试代码如下: <?php try { $dsn = 'mysql:dbname=php-note;host=localhost;port=3306;charset=utf8'; $username = 'root'; $password = 'root'; new PDO( $dsn,

Mysql报错 :Unknown table engine &#39;InnoDB&#39; &nbsp;

问题: zabbix服务器重启后,进入zabbix的web发现登录不进去并且网页报mysql的错误,查看mysql的日之后,发现报错: [[email protected] ~]# tail -f /var/log/mysqld.log 140820 16:24:43 [Note] /usr/libexec/mysqld: ready for connections. Version: '5.1.73'  socket: '/var/lib/mysql/mysql.sock'  port: 33

mysql报错序号对应的错误

mysql报错序号对应的错误 1005:创建表失败 1006:创建数据库失败 1007:数据库已存在,创建数据库失败<=================可以忽略 1008:数据库不存在,删除数据库失败<=================可以忽略 1009:不能删除数据库文件导致删除数据库失败 1010:不能删除数据目录导致删除数据库失败 1011:删除数据库文件失败 1012:不能读取系统表中的记录 1020:记录已被其他用户修改 1021:硬盘剩余空间不足,请加大硬盘可用空间 1022:关键

mysql报错排查总结

mysql报错: [[email protected] ~]# mysql ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock' (2) 问题排查总结: 问题1: mysqld 守护进程是否启动 解决: [[email protected] mysql]# service mysqld start Starting mysqld: [ OK ] [[em

mysql报错问题解决Character set &#39;utf8mb4&#39; is not a compiled character set

mysql: Character set 'utf8mb4' is not a compiled character set and is not specified in the '/usr/share/mysql/charsets/Index.xml' file 报错的解决方法 1.由于日常程序使用了字符集utf8mb4,为了避免每次更新时,set names utf8mb4,就把配置文件改了,如下: 增加了mysql客户端的默认字符集设置 [[email protected]~]# vim

解决mysql报错Can’t connect to local MySQL server through socket ‘/var/lib/mysql/mysql.sock’

启动mysql 报错: ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock' (2) 1.先查看 /etc/rc.d/init.d/mysqld status 看看m y s q l 是否已经启动.另外看看是不是权限问题. 2.确定你的mysql.sock是不是在那个位置,mysql -u 你的mysql用户名 -p -S /var/lib/mysql/