MySQL 5.6.16 DATETIME字段DEFAULT CURRENT_TIMESTAMP无法正常工作

时间:2014-02-21 18:48:35

标签: php mysql macos datetime default-value

我有两台运行自制软件的Mac(MySQL 5.6.16和PHP 5.5.8),笔记本电脑(10.7)和服务器(10.9服务器)。它们运行相同的源代码。我昨天在两台机器上运行了mysql_install_db和mysql_upgrade。

(记录不同步) 以下是show create table persons的diff输出:( macbook left,server right)

< ) ENGINE=InnoDB AUTO_INCREMENT=128928 DEFAULT CHARSET=latin1
---
> ) ENGINE=InnoDB AUTO_INCREMENT=128432 DEFAULT CHARSET=latin1

除自动增量外,它们具有相同的表定义。

以下是show variables的diff输出:(macbook left,server right)

35c35
< datadir       /Applications/MAMP/db/mysql/
---
> datadir       /usr/local/mysql/data/    
82c82
< hostname      Bradley-Slavik-MacBook.local
---
> hostname      www.opinionwizard.com
212c212
< key_buffer_size       268435456
---
> key_buffer_size       402653184
326c326
< pid_file      /var/mysql/mysql.pid
---
> pid_file      /usr/local/mysql/data/www.opinionwizard.com.pid
335c335
< pseudo_thread_id      52
---
> pseudo_thread_id      5
366c366
< server_uuid   6356280a-847d-11e3-a2cd-3912ad30e5ec
---
> server_uuid   51d7bac8-e421-11e2-8d20-1d8e718a624d
388c388
< slow_query_log_file   /Applications/MAMP/db/mysql/Bradley-Slavik-MacBook-slow.log
---
> slow_query_log_file   /usr/local/mysql/data/www-slow.log
428c428
< timestamp     1392999311.730679
---
> timestamp     1393006691.207529
441c441
< version_compile_os    osx10.7
---
> version_compile_os    osx10.9

(显示全局变量具有相同的差异,缺少pseudo_thread_id和timestamp)

但是,当我在没有指定enter_date的情况下在macbook上保存记录时,它被正确设置为current_timestamp。在服务器上,我收到此错误:

Invalid datetime format: 1292 Incorrect datetime value: 'CURRENT_TIMESTAMP' for column 'enter_date' at row 1

以下是整个消息,以防有人可以阅读:

{"status":"Internal Server Error","code":500,"text":"SQLSTATE[22007]: Invalid datetime format: 1292 Incorrect datetime value: 'CURRENT_TIMESTAMP' for column 'enter_date' at row 1","trace":[{"file":"\/Users\/ow_dev\/fatfree-3.2.0\/lib\/DB\/SQL.php","line":143,"function":"execute","class":"PDOStatement","type":"->","args":[]},{"file":"\/Users\/ow_dev\/fatfree-3.2.0\/lib\/DB\/SQL\/Mapper.php","line":346,"function":"exec","class":"DB\\SQL","type":"->","args":["INSERT INTO `individuals` (`last_edited_by_employee_id`,`last_edited_date`,`opt_in_date_time`,`phone_count`,`household_id`,`firstname`,`lastname`,`email_address`,`password`,`birthdate`,`adult_contact`,`language_id`,`allow_household_edit`,`entered_by_employee_id`,`enter_date`,`gender`,`marital_status_id`,`education_id`,`work_status_id`,`political_id`,`ethnicity_id`,`industry_id`,`headquarters`,`work_title`,`company_name`,`company_email`,`company_address1`,`company_address2`,`company_city`,`company_state`,`company_zip`,`company_country`,`company_revenues_id`,`company_local_employees_id`,`company_total_employees_id`,`status`,`status_date`,`inactive_reason_id`,`defer_to_date`,`times_no_showed`,`times_canceled`,`times_late`,`times_not_qualified`,`times_excused`,`times_used`,`sign_up_category`,`other_inactive_reason`) VALUES (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)",{"1":[2,1],"2":["2014-02-21 12:17:21",2],"3":["0000-00-00 00:00:00",2],"4":[0,1],"5":[52992,1],"6":["Chloe",2],"7":["Hans",2],"8":["",2],"9":["",2],"10":["2008-12-17",2],"11":[66400,1],"12":[1,1],"13":["No",2],"14":[0,1],"15":["CURRENT_TIMESTAMP",2],"16":["Female",2],"17":[0,1],"18":[0,1],"19":[0,1],"20":[0,1],"21":[1,1],"22":[0,1],"23":[0,1],"24":["",2],"25":["",2],"26":["",2],"27":["",2],"28":["",2],"29":["",2],"30":["--",2],"31":["",2],"32":[0,1],"33":[0,1],"34":[0,1],"35":[0,1],"36":[2,1],"37":["2014-02-21 12:17:21",2],"38":[0,1],"39":["0000-00-00",2],"40":[0,1],"41":[0,1],"42":[0,1],"43":[0,1],"44":[0,1],"45":[0,1],"46":["consumer",2],"47":["",2]}]},{"file":"\/Users\/ow_dev\/fatfree-3.2.0\/lib\/DB\/Cursor.php","line":192,"function":"insert","class":"DB\\SQL\\Mapper","type":"->","args":[]},{"file":"\/Users\/ow_dev\/OpinionWizard\/libs\/Individual.php","line":611,"function":"save","class":"DB\\Cursor","type":"->","args":[]},{"file":"\/Library\/Server\/Web\/Data\/Sites\/dev.opinionwizard.com\/individualSave.php","line":49,"function":"saveIndividual","class":"individual","type":"->","args":[]}]}

我可以看到'CURRENT_TIMESTAMP'作为参数15传递,这是正确的。

我之前已经注意到服务器比我的macbook更加挑选关于获取正确类型的数据的问题。我一直在更新我的代码要严格得多,并将更改迁移到生产中。这次DEFAULT值应该提供值,并且似乎是提供值。我之前没有仔细查看配置,我认为我的生产服务器上有一些更严格的设置,而我的macbook上没有这个设置,但我觉得唯一不同的是操作系统的版本( 10.7 vs 10.9)。我在最后一天多次重启数据库服务器和apache,因此配置文件中的所有设置都应该生效。

我应该关注PHP设置吗? mysql中的其他一些命令可以获得除show变量之外的配置吗?在可能导致生产服务器不那么宽容或灵活的环境中应该检查什么?

0 个答案:

没有答案