MySQL replication exception problem caused by inconsistent column type of library

Source: Internet
Author: User

Official documents:

slave_type_conversions   This parameter is in mysql5.5.3 introduced to enable row bin-log when the master-slave column mysql5.5.3 after support, the main library is int from library is bigint this type of replication,

The meaning of this parameter is to control some types of conversion tolerance.

If the field type range from the library is larger than the main library type, set Slave_type_conversions=all_non_lossy post-replication is not a problem.

If the library type is smaller than the main library type, such as from int copied to tinyint , although you can set the Slave_type_conversions=all_lossy,all_non_lossy let the master and slave do not problem, but actually can cause the risk of data loss.

settings for several values:

All_lossy : Allow data truncation

All_non_lossy : data truncation is not allowed, if from the library type is larger than the main library type, it can be replicated, reversed, and not, replication error from the library, replication terminated.

All_lossy,all_non_lossy: all allowed conversions are performed, regardless of data loss.

null value (not set): requires the master/slave library data type must be strictly consistent, otherwise all error.




In this mode, type conversions that would mean loss of information is permitted.

This does isn't imply that non-lossy conversions is permitted, merely that's only cases requiring either lossy conversi ONS or no conversion at all is permitted; For example, enabling onlyThis mode permits anINTcolumn to Bes converted toTINYINT(a lossy conversion), but not aTINYINTcolumn to anINTcolumn (Non-lossy). Attempting the latter conversion in this case would cause replication to stop with a error on the slave.


This mode permits conversions that does not require truncation or other special handling of the source value; It permits conversions where the target type has a wider range than the source type. "Make sure that the column type from the library is broader and does not result in replication errors"

Setting This mode have no bearing on whether lossy conversions be permitted; this was controlled with theAll_lossymode. If onlyAll_non_lossyis set, and notAll_lossy, then attempting a conversion so would result in the loss of data (such asINT toTINYINT, orCHAR (+) toVARCHAR (+)) causes the slave to stop with an error.


when This mode was set, all supported type conversions be permitted, whether  or not they be lossy conversions.


treat promoted integer types as signed values (the default behavior).


treat promoted integer types as unsigned values.


treat promoted integer types as signed if possible, otherwise as  unsigned.

[ empty "

when slave_type_conversions is not set, no attribute promotion or demotion are permitted; This means that all columns in the source and target T Ables must be of the same types.

This mode is the default.

production Environment one case:

from the library there is a Oracle system to check the data, the original from the library cp_shop_activity represents UTF8MB4 Character Set, Oracle not supported. Therefore , the character type of the mode field modified manually from the library is varchar (UTF8), and the Modified field type is as follows:

650) this.width=650; "src=" Https:// "title=" 11. PNG "alt=" Wkiol1jkjpew8-svaaau7-trnsw434.png "/>

but not a few days later, found that the master-slave replication error, the wrong code 1677 . The error log logged from the library is as follows:

650) this.width=650; "src=" Https:// "title=" 22. PNG "alt=" Wkiol1jkjtnwqkpjaadpzg4p9u0623.png "/>

We look at the main library's mode field is varchar, from the library's mode field is varchar ($).

650) this.width=650; "src=" Https:// "title=" 44. PNG "alt=" Wkiol1jkjcfhgrwvaaaszsdd6hm836.png "/>

In the From Library settings:

Stop slave;

set global slave_type_conversions=all_non_lossy;

# default slave_type_conversions is empty, which means that the field type of the library and the main library is forced to match, or the copy is stopped. setting to All_non_lossy is a bit more general and ensures that no type conversions are caused.

Start slave;

Show Slave Status\g

This solves the problem.

This article is from the "do-it-yourself MySQL chicken" blog, make sure to keep this source

MySQL replication exception problem caused by inconsistent column type of library

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.