You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

TIMESTAMP字段无法设置默认值?执行ALTER语句遇1067未知错误求助

Troubleshooting Your TIMESTAMP Default Value Error

Let’s tackle your two questions head-on, since they’re linked by MySQL’s timestamp behavior and your active SQL mode settings.

Why isn’t the error showing a specific message?

Error code 1067 in MySQL directly relates to invalid default values, but in some cases—especially with older MySQL versions or certain client tools (like specific phpMyAdmin configurations)—the full error description doesn’t get displayed. The "Unknown error" label here is just a missing detail; the root cause is that your proposed default value isn’t valid for the TIMESTAMP column.

Why can’t you set '1970-01-01 00:00:01' as the TIMESTAMP default?

The key issue here is time zone conversion combined with MySQL’s strict TIMESTAMP range limits:

  • TIMESTAMP columns store values internally as UTC timestamps, with a strict valid range from '1970-01-01 00:00:01' UTC to '2038-01-19 03:14:07' UTC.
  • If your MySQL server’s time zone isn’t set to UTC (e.g., UTC+8, UTC-5), the value '1970-01-01 00:00:01' you’re specifying will be converted to UTC. For example, a UTC+8 time zone would turn this local time into '1969-12-31 16:00:01' UTC, which falls below the minimum valid TIMESTAMP value. MySQL rejects this as invalid.
  • Your sql_mode includes NO_ZERO_DATE, which correctly blocks the old '0000-00-00 00:00:00' default (an invalid "zero date"), but this isn’t the issue with your new proposed value—it’s the time zone-induced range violation.

Fixes to Try

  • Adjust the default for your time zone: Use a local time that converts to a valid UTC timestamp. For a UTC+8 server, '1970-01-01 08:00:01' local time maps to '1970-01-01 00:00:01' UTC, which is valid.
  • Set server time zone to UTC: If your application can tolerate UTC timestamps, configuring MySQL to use UTC removes the conversion issue entirely, making '1970-01-01 00:00:01' a valid default.
  • Switch to DATETIME: If you don’t need TIMESTAMP’s automatic time zone conversion behavior, changing the column type to DATETIME avoids the UTC range limits (though it still won’t accept zero dates with your current sql_mode).

内容的提问来源于stack exchange,提问作者Itay Moav -Malimovka

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.15 06:28:14