"ERROR 1406: 1406: Data too long for column" but it shouldn't be?

isadmin is a column of type bit and you are storing a value of type varchar in it which is of larger size than bit. modify query as follows:-

UPDATE `tblusers` SET `IsAdmin`=b'1'  WHERE `UserID`='79';

IsAdmin has the datatype of bit(1), yet you are assigning the string '1' to it. Indicate that you are assigning a bit value to it by preceeding the '1' with b or use 0b format:

UPDATE `tblusers` SET `IsAdmin`=b'1'  WHERE `UserID`='79';

or

UPDATE `tblusers` SET `IsAdmin`=0b1  WHERE `UserID`='79';

The reason for this behaviour is probably that strict_all_tables or strict_trans_tables setting is enabled on the v5.7 mysql server:

Strict mode controls how MySQL handles invalid or missing values in data-change statements such as INSERT or UPDATE. A value can be invalid for several reasons. For example, it might have the wrong data type for the column, or it might be out of range. A value is missing when a new row to be inserted does not contain a value for a non-NULL column that has no explicit DEFAULT clause in its definition. (For a NULL column, NULL is inserted if the value is missing.) Strict mode also affects DDL statements such as CREATE TABLE.

Tags:

Mysql