mysql 导入时遇到 的解决 Variable ‘time_zone‘ can‘t、‘character_set_client‘问题

mysql在导入文件时,提示如下错误

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‘

方法1.临时解决

mysql> set max_allowed_packet=1024M;  --只对当前会话生效
mysql> source ./xxxx.sql;

方法2.修改mysql配置文件:

[mysqld]
max_allowed_packet=1024M

方法3.打开导入文件,删除结尾处的相关报错行

在sql文件末尾注释该条sql语句,前面加#号或删除

[root@rocky01 ~]# vim /root/test.sql
#原
/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */;

#注释后
#/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */;

你可能感兴趣的:(MySQL,mysql)