安装好了 wordpress,今天 MySQL 数据库 ALTER TABLE wp_comments 时出现了报错:
Error Code: 1067. Invalid default value for ‘comment_date’ |
the lead developer of WordPress wrote:
“WordPress just pretty simply does not support strict mode.”
So the solution is to disable strict mode on MySQL. It’s a pity.
In the WordPress code, you can find includes/wp-db.php which lists:
/** |
Set the sql_mode option in your my.cnf file to omit those sql modes. You can keep other sql modes, like the ones in the default set of sql modes for MySQL 5.7:
[mysqld] |
注意:配置文件里 sql-mode 中间是连字符,并非下划线。后面的值用双引号包裹。
You can also change the global sql mode set without needing to restart the MySQL Server(重启会失效):
mysql> SET GLOBAL sql_mode = 'ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION'; |
附:查询 sql_mode 的方法:
-- 查看当前连接的数据库模式 |
扫描二维码,分享此文章