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

2023-12-13 21:39:28

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 */;

文章来源:https://blog.csdn.net/jugtba/article/details/134910442
本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。