Validate the data before inserting it into your database. If a string is too big to fit in your table, either your column is too narrow, or the data is invalid. You need to decide whether you truncate it before storing it, do some error reporting, or both.
Do not turn off the safety features of your DBMS, that's the completely wrong thing to do.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…