title: laravel 5.4 specified key was too long, why the number 191
body: <p>I know this problem is discussed, and solved or closed.<br>
  But what I want to ask is, why is the number 191?</p>
  
  <pre><code>Schema::defaultStringLength(191);
  </code></pre>
  
  <p>I tried: if 192, wrong. 191, ok.
  After this, I also edit database\migrations\xxx_user_table.php<br>
  Change this</p>
  
  <pre><code>$table-&gt;string('name');
  </code></pre>
  
  <p>to be</p>
  
  <pre><code>$table-&gt;string('name', 255);
  </code></pre>
  
  <p>Then run php artisan migrate, it's ok.
  Use some mysql tool to see the schema of user table, 
  length of name which is varchar is actually 255, others columns are 191.</p>
  
  <p>I saw these articles<br>
  @ <a href="https://laravel-news.com/laravel-5-4-key-too-long-error" rel="noreferrer">https://laravel-news.com/laravel-5-4-key-too-long-error</a><br>
  @ <a href="https://stackoverflow.com/questions/23786359/laravel-migration-unique-key-is-too-long-even-if-specified">Laravel migration: unique key is too long, even if specified</a><br>
  @ <a href="https://github.com/laravel/framework/issues/17508" rel="noreferrer">https://github.com/laravel/framework/issues/17508</a><br>
  @ <a href="https://laravel.com/docs/master/migrations#creating-indexes" rel="noreferrer">https://laravel.com/docs/master/migrations#creating-indexes</a>  </p>
  
  <p>And this:
  @ <a href="https://dev.mysql.com/doc/refman/5.7/en/innodb-restrictions.html" rel="noreferrer">https://dev.mysql.com/doc/refman/5.7/en/innodb-restrictions.html</a></p>
  
  <blockquote>
    <p>The index key prefix length limit is 767 bytes for InnoDB tables that
    use the REDUNDANT or COMPACT row format. For example, you might hit
    this limit with a column prefix index of more than 255 characters on a
    TEXT or VARCHAR column, assuming a utf8mb3 character set and the
    maximum of 3 bytes for each character.</p>
  </blockquote>
  
  <p>But why length 255 of name is ok?<br>
  And 192*3 = 576, smaller than 767, why 192 not ok?</p>