1. 程式人生 > 資料庫 >插入MySQL報錯‘pymysql.err.DataError: (1406, "Data too long for column 'url' at row 1&quot

插入MySQL報錯‘pymysql.err.DataError: (1406, "Data too long for column 'url' at row 1&quot

錯誤重現:

插入MySQL報錯‘pymysql.err.DataError: (1406, "Data too long for column 'url' at row 1")’

解決方法:

在插入MySQL的字元太多,此時將MySQL的模式改為非嚴格模式。
MySQL中執行:
mysql> SET @@global.sql_mode= '';

【搬運國外大神解釋】

MySQL will truncate any insert value that exceeds the specified column width.

to make this without error try Switch your MySQL mode to not use STRICT.