當我們使用 migrate 出現以下訊息:
SQLSTATE[42000]: Syntax error or access violation: 1071 Specified key was too long; max key length is 767 bytes
這個問題出現在Laravel 5.4版本之後,調整方式如下
解決方式(一):
在 migrate 中使用 unique() 時指定長度為191,必須修改每一個有使用到 unique() 的migrate檔案
$table->string('email', 191)->unique();
解決方式(二):
編輯 app\Providers\AppServiceProvider.php 增加
use Schema;
並在boot funciton內增加
Schema::defaultStringLength(191);
完整程式碼如下:
namespace App\Providers;
use Illuminate\Support\ServiceProvider;
use Schema;
class AppServiceProvider extends ServiceProvider
{
/**
* Bootstrap any application services.
*
* @return void
*/
public function boot()
{
Schema::defaultStringLength(191);
}
}
大多數網站會員註冊都依賴Email作為主要驗證機制,當驗證Email寄給使用者後,卻又直接進入垃圾信箱,經常被抱怨收不到信!
對於 MySQL 資料庫資料操作的基本語法大全
<a>標籤為超連結,是HTML標籤中最常使用到的標籤 href屬性為目標位置,可輸入絕對位置或相對位置 比較特別的是target屬性,設定連結的框架或視窗
CentOS 7 安裝後會自帶Python2,如果需要使用Python3則需要再另行安裝,安裝方式
使用CentOS作為伺服器主機,完整架設流程