amazon rds - How to import MySQL binlog that contains INSERTs of a TIMESTAMP field with default value CURRENT_TIMESTAMP -
i have database i'm attempting migrate amazon rds. i'm following instructions https://engineering.gosquared.com/migrating-mysql-to-amazon-rds.
i've done mysqldump of original server, , i've imported data rds server. now, i'm ready import changes have occurred since mysqldump. when pipe output of mysqlbinlog mysql, error null value.
my table has timestamp field called datereceived
default value of current_timestamp. when our app inserts records, leaves datereceived
null database handles populating current time.
when try import mysqlbinlog, chokes on null value inserts.
here's snippet of output mysqlbinlog:
begin /*!*/; # @ 42615369 #130813 13:41:12 server id 60 end_log_pos 42615397 intvar set insert_id=173164716/*!*/; # @ 42615397 #130813 13:41:12 server id 60 end_log_pos 42618804 query thread_id=680551 exec_time=0 error_code=0 use mydatabase/*!*/; set timestamp=1376426472/*!*/; insert email_history (`from`, `subject`, `datereceived`) values ('someone@acme.com', 'fw: message', null) /*!*/; # @ 42618804 #130813 13:41:12 server id 60 end_log_pos 42618831 xid = 37399491
the error mysql when attempting import is:
error 1048 (23000) @ line 28: column 'datereceived' cannot null
here's how table structured:
mysql> describe email_history; +--------------+------------------------------+------+-----+-------------------+----------------+ | field | type | null | key | default | | +--------------+------------------------------+------+-----+-------------------+----------------+ | | varchar(512) | yes | mul | null | | | subject | varchar(512) | yes | mul | null | | | datereceived | timestamp | no | mul | current_timestamp | | +--------------+------------------------------+------+-----+-------------------+----------------+ 3 rows in set (0.00 sec)
how can import binlog?
i found answer, , sharing here of community.
there's new system variable introduced in mysql 5.6.6, called "explicit_defaults_for_timestamp". value set false, code above work. if set true, though, mysql gives error.
unfortunately, amazon rds doesn't allow change parameter, , it's not able set on per-session basis.
mysql> set session explicit_defaults_for_timestamp=false; error 1238 (hy000): variable 'explicit_defaults_for_timestamp' read variable
you can read more variable here.
Comments
Post a Comment