Search code examples
mysqldatabasetruncation

Data truncated in MySQL database I need more idea what causes this?


I always got this warning message everytime I insert data row for username and password. The function I used is MD5 for password and Current User for username.

What I did is leaving the function blank for username and password, and now it inserted successfully without warning, but of course I can't leave password unencypted.

I tried to search the internet for this kind of problem but they are complicated to understand. What I need to know is what causes this problem everytime I set the function for the row the warning occur?

This is the warning says.

1 row inserted.

Warning: #1265 Data truncated for column 'username' at row 1

Warning: #1265 Data truncated for column 'password' at row 1


Solution

  • It just means that the length of the value you are inserting is greater than the length defined on the column.

    Alter the columns username and password to length 32 because MD5 returns a string of 32 hex digits.