今天在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