MySQL 执行SQL脚本 报ERROR 1231 (42000)的解决办法【转】

今天在source mysqldump 备份文件时,发现导入的过程中报如下的错误:

ERROR 1231 (42000): Variable 'time_zone' can't be set to the value of 'NULL'

ERROR 1231 (42000): Variable 'sql_mode' can't be set to the value of 'NULL'

ERROR 1231 (42000): Variable 'foreign_key_checks' can't be set to the value of 'NULL'

ERROR 1231 (42000): Variable 'unique_checks' can't be set to the value of 'NULL'

ERROR 1231 (42000): Variable 'character_set_client' can't be set to the value of 'NULL'

ERROR 1231 (42000): Variable 'collation_connection' can't be set to the value of 'NULL'

ERROR 1231 (42000): Variable 'sql_notes' can't be set to the value of 'NULL'

解决方法:

mysql> set max_allowed_packet=1024M;  --只对当前会话生效

mysql> source ./xxxx.sql;

如果MySQL版本不允许在线修改,就只能修改my.cnf

vi /opt/my.cnf

set max_allowed_packet=1024M;

重启数据库

service mysql restart

转自

MySQL 执行SQL脚本 报ERROR 1231 (42000)的解决办法 - 小鱼的博客 - 51CTO技术博客
http://395469372.blog.51cto.com/1150982/1729451

上一篇:程序代码中退出函数exit()与返回函数return ()的区别


下一篇:Python2/3的中、英文字符编码与解码输出: UnicodeDecodeError: 'ascii' codec can't decode/encode