Home Coding & Programming Laravel: String data, right truncated: 1406 Data too long for column (SOLVED)

Laravel: String data, right truncated: 1406 Data too long for column (SOLVED)

I was working on a project today when i ran into the error message “String data, right truncated: 1406 Data too long for column ‘name’ at row 1” which appeared to be originating from my database. After resolving the issue i decided to drop a guide on how anyone can resolve similar issue if encountered in future.

If you are encountering such error, then it means the value being entered is as the error says “too long for the column”. On your local development, try changing the column type to:

$table->longText('columnName')

But if you have gone live, then create a new migration and then use longText() column type.
$table->text(‘columnName’) should be enough for most of the cases but since you might be dealing with a larger text character number, then $table->longText(‘columnName’) should be your fall back.

Here is a more simpler approach if you have already gone live;

  • Login into your server’s phpMyAdmin for the database.
  • Navigate to the table that is the source of the error message.
  • Once you have located the table, click on it. For clarity, i am making use of a test table i created.
  • Next in the table page, locate and click on Structure just as illustrated in the image below.
String data, right truncated
  • Locate the column name which was probably specified in the error message you received and click on the Change label.
  • Click on the drop down button for Type and scroll down to select the LONGTEXT string type.
  • Finally click on Save and you are done.

This is what resolved the error i was getting. I hope you find this helpful.

LEAVE A REPLY

Please enter your comment!
Please enter your name here

Most Popular

List of All JavaScript Arithmetic Operators With Examples

JavaScript offers several operators to help us work with numbers. All these operators are binary operators, which means they operate on two operands. The operands...

How to Find a Website’s RSS Feed’s URL

Having access to the RSS feed of a website gives you the opportunity to stay up-to-date on everything that website publishes. Whether that’s a...

Laravel: String data, right truncated: 1406 Data too long for column (SOLVED)

I was working on a project today when i ran into the error message "String data, right truncated: 1406 Data too long for column...

How to Enable or Disable Chrome’s Autofill on Android Devices

Storing your login details and other information in Chrome and/or your Google Account isn’t as secure as using an encrypted password manager, but it’s...

Recent Comments