LoginSignup
2
0

More than 5 years have passed since last update.

MAMPのMYSQLをlarvalで使う

Last updated at Posted at 2018-01-04

MAMPのMYSQLをlarvalで使う

.envファイルの編集

  • 使用するDatabase名とUserName, Passwordを変更する。
.env
DB_CONNECTION=mysql
DB_HOST=127.0.0.1
DB_PORT=3306
DB_DATABASE=board
DB_USERNAME=root
DB_PASSWORD=root

config/database.phpの編集

  • database, username, password, unix_socketを変更する。
config/database.php
'mysql' => [
  'driver' => 'mysql',
  'host' => env('DB_HOST', '127.0.0.1'),
  'port' => env('DB_PORT', '8889'),
  'database' => env('DB_DATABASE', 'laravel'),
  'username' => env('DB_USERNAME', 'root'),
  'password' => env('DB_PASSWORD', 'root'),
  'unix_socket'   => env('DB_SOCKET', '/Applications/MAMP/tmp/mysql/mysql.sock'),
  'charset' => 'utf8mb4',
  'collation' => 'utf8mb4_unicode_ci',
  'prefix' => '',
  'strict' => true,
  'engine' => null,
],

app/Providers/AppServiceProvider.phpの編集

app/Providers/AppServiceProvider.php
<?php
  namespace App\Providers;

  use Illuminate\Support\ServiceProvider;

  #以下の1行を追記
  use Illuminate\Support\Facades\Schema;

  class AppServiceProvider extends ServiceProvider
  {   
    public function boot()
    {        
      #以下の1行を追記
      Schema::defaultStringLength(191);
     }

    public function register()
    {   
         //
     }
  }
?>
2
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
2
0