LoginSignup
14
13

More than 5 years have passed since last update.

LaravelでMAMPのMySQLに接続する

Posted at

Laravelをローカルで起動した時にMAMPのMySQLに接続できなくてはまった。

起動している環境情報の確認

localかproductionか確認する。

php artisan env

データベース接続情報を設定する

localであればapp/config/local/database.phpを
productionであれば、app/config/database.phpを編集する。

これをconnections=>mysqlに追加する。

'unix_socket'   => '/Applications/MAMP/tmp/mysql/mysql.sock',

下記のように追加。

'connections' => array(
        'mysql' => array(
            'driver'    => 'mysql',
            'host'      => 'localhost',
            'database'  => 'forge',
           'unix_socket'   => '/Applications/MAMP/tmp/mysql/mysql.sock',
            'username'  => 'forge',
            'password'  => '',
            'charset'   => 'utf8',
            'collation' => 'utf8_unicode_ci',
            'prefix'    => '',
        ),
    ),
14
13
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
14
13