1.mysqldump 5.0 server data and, import to 5.6 server
2. let 5.0 be master and 5.6 be slave, replication
3. ensure all the sql statements are correct
4. change 5.6 to master
NOTICE :
Some statement could execute by replication but generate error when change 5.6 to master
because sql_mode is strict sql mode
reference :
https://dev.mysql.com/doc/refman/5.0/en/sql-mode.html
https://dev.mysql.com/doc/refman/5.0/en/server-system-variables.html#sysvar_sql_mode
examples :
CREATE TABLE `test2` (
`no` INT( 11 ) NOT NULL AUTO_INCREMENT ,
`data1` INT( 11 ) NOT NULL ,
`PS` TINYTEXT NOT NULL ,
`sdate` DATETIME NOT NULL ,
PRIMARY KEY ( `no` )
)`data1` INT( 11 ) NOT NULL ,
`PS` TINYTEXT NOT NULL ,
`sdate` DATETIME NOT NULL ,
PRIMARY KEY ( `no` )
A.
INSERT INTO test2( `no` , `data1` , `PS` , `sdate` )
VALUES (
'', 1, "testps", '2015-05-12 18:00:00'
)#1366 - Incorrect integer value: '' for column 'no' at row 1
B.
INSERT INTO test2( `no` , `data1` , `sdate` )
VALUES (
NULL , 1, '2015-05-12 18:00:00'
)#1364 - Field 'PS' doesn't have a default value
C.
INSERT INTO test2( `no` , `data1` , `sdate` )
VALUES (
NULL , 1, '2015-05-12 18:00:00'
)#1292 - Incorrect datetime value: '' for column 'sdate' at row 1
D.
INSERT INTO test2( `no` , `data1` , `PS` , `sdate` )
VALUES (
NULL , 1, 'pstest', '0000-13-00 00:00:00'
)#1292 - Incorrect datetime value: '0000-13-00 00:00:00' for column 'sdate' at row 1
In none-strict sql mode or in 5.0, those statements will be executed correctly.
The correct form should be
INSERT INTO `test2` (`no`, `data1`, `PS`, `sdate` ) VALUES (NULL, 1, 'pstest', '0000-00-00 00:00:00');
or
INSERT INTO `test2` (`no`, `data1`) VALUES (0, 1, 'pstest', '0000-00-00 00:00:00');
or
INSERT INTO `test2` (`data1`) VALUES (1, 'pstest', '0000-00-00 00:00:00');
To disable strict_sql_mode (reference)
1. check default sql_mode by
mysql> select @@sql_mode;
+------------------------+
| @@sql_mode |
+------------------------+
| NO_ENGINE_SUBSTITUTION, STRICT_TRANS_TABLES |
+------------------------+
2. in my.cnf, change
sql_mode="NO_ENGINE_SUBSTITUTION, STRICT_TRANS_TABLES"
to
sql_mode="NO_ENGINE_SUBSTITUTION"
沒有留言:
張貼留言