MySQL——报错及解决方案,
MySQL——报错及解决方案
摘要:本文主要记录了在使用MySQL的过程中遇到的问题以及解决方案。
定义timestamp类型的数据
相关日志
1 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details).
解决办法
在配置文件中加入:
1 [mysqld] 2 # explicit_defaults_for_timestamp 3 explicit_defaults_for_timestamp=true
问题说明
MySQL5.6.6以前:
如果timestamp类型的列指定值为null,默认为当前timestamp。
如果timestamp类型的列没有指定值为null,也就是没有传值,默认为非null的一个值。
表中第一个timestamp列,如果没有指定值为null、也没有设置默认值,在插入和更新时都会设置为当前时间。
表中第一个timestamp列之后的所有timestamp列,如果没有被定义为null、定义default值,会设置为'0000-00-00 00:00:00'。
MySQL5.6.6以后,需要在配置文件里设置 explicit_defaults_for_timestamp=true ,其含义为:
如果timestamp类型的列指定值为null,默认为当前timestamp。
如果timestamp类型的列没有指定值为null,也就是没有传值,默认为null。
声明timestamp类型的列不为能为null,而且没有指定默认值。在插入时timestamp类型的列没有指定值,如果是严格sql模式,会抛出一个错误,如果严格sql模式没有启用,该列会赋值为‘0000-00-00 00:00:00’,同时出现警告。
导入导出权限设置
相关日志
1 [Note] --secure-file-priv is set to NULL. Operations related to importing and exporting data are disabled. 2 [Warning] Insecure configuration for --secure-file-priv: Current value does not restrict location of generated files. Consider setting it to a valid, non-empty path. 3 [ERROR] Failed to access directory for --secure-file-priv. Please make sure that directory exists and is accessible by MySQL Server.
解决办法
在配置文件中加入:
1 [mysqld] 2 # 设置导入导出 3 secure-file-priv=D:\All\MySQL\file
问题说明
配置文件里的 secure-file-priv 参数是用来限制将数据导入导出到指定目录的:
当值为null,表示不允许导入导出操作。
当值为具体的文件夹,表示导入导出只能在该目录下操作,目录不存在会报错。
当值没有具体值时,表示不限制导入导出操作的文件夹。
本站文章为和通数据库网友分享或者投稿,欢迎任何形式的转载,但请务必注明出处.
同时文章内容如有侵犯了您的权益,请联系QQ:970679559,我们会在尽快处理。