2015-05-18 163 views

回答

2

在您的.env文件中,您需要設置數據庫配置值以匹配您的數據庫配置。使用您當前的設置,您嘗試以root用戶身份登錄到數據庫,而無需輸入密碼。

你說你在使用MAMP和MAMP下的默認MySQL密碼是root,所以你的.env應該有這些數據庫值。

DB_HOST=localhost 
DB_DATABASE=laravel 
DB_USERNAME=root 
DB_PASSWORD=root 

顯然,您還需要確保有一個名爲laravel的數據庫。

NOTE: Don't run this configuration in a production environment or any environment where security is important. It's ok for development, but for a production server I would recommend giving Laravel its own database user, and only granting that user permissions for your laravel database.

1

如果你使用MAMP,你需要添加一些東西。

在你.env添加此..

DB_UNIX_SOCKET=/Applications/MAMP/tmp/mysql/mysql.sock 
DB_PORT=8889 

如果你改變了你的MySQL MAMP端口更改這裏。

然後在你的database.php配置添加unix_socketport ..

'mysql' => [ 
    'unix_socket' => env('DB_UNIX_SOCKET', ''), 
    'port'   => env('DB_PORT', '3306'), 
],