django-在生成表失败的记录
说明: 因为是在学习django 所以创建表的class就不把代码粘出来了,仅记录 报错与解决方法
执行命令报错信息
python manage.py makemigrations
pymysql.err.OperationalError: (1665, 'Cannot execute statement: impossible to write to binary log since BINLOG_FORM
AT = STATEMENT and at least one table uses a storage engine limited to row-based logging. InnoDB is limited to row-
logging when transaction isolation level is READ COMMITTED or READ UNCOMMITTED.')
解决方法 : 需要修改mysql数据库参数
show variables like '%binlog_format%'
set global binlog_format=row;
以下从参考博客考过来的问题原因
This is required by MySQL:
This is required by MySQL: Statement based binlogging does not work in isolation level READ UNCOMMITTED and READ COMMITTED since the necessary locks cannot be taken.
根据tomcat抛异常,提示是事务级别在read committed和read uncommitted的时候binlog必须设置为row格式。
这个是java设置的一个局限性,java默认的事务级别是read committed,而mysql默认设置的binlog_format=statement。
将binlog_format设置为mixed
set global binlog_format=mixed;
过段时间,异常仍在!
设置成row
set global binlog_format=row;
问题解决!
或:
mysql> SET SESSION binlog_format = 'ROW';
mysql> SET GLOBAL binlog_format = 'ROW';
注意: 若手动修改linux下面/etc/my.cnf : binlog_format = row , 需要重启mysql。

浙公网安备 33010602011771号