我有以下錯誤: Laravel 5遷移錯誤1045
按照本指南後: http://tutsnare.com/access-denied-for-user-homesteadlocalhost-laravel-5/
我改變了我的.ENV文件按照指南,但我仍然收到這個錯誤。其他人知道如何解決這個問題嗎?另外我在本地主機上使用MAMP。謝謝。
我有以下錯誤: Laravel 5遷移錯誤1045
按照本指南後: http://tutsnare.com/access-denied-for-user-homesteadlocalhost-laravel-5/
我改變了我的.ENV文件按照指南,但我仍然收到這個錯誤。其他人知道如何解決這個問題嗎?另外我在本地主機上使用MAMP。謝謝。
在您的.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.
如果你使用MAMP,你需要添加一些東西。
在你.env
添加此..
DB_UNIX_SOCKET=/Applications/MAMP/tmp/mysql/mysql.sock
DB_PORT=8889
如果你改變了你的MySQL MAMP端口更改這裏。
然後在你的database.php
配置添加unix_socket
和port
..
'mysql' => [
'unix_socket' => env('DB_UNIX_SOCKET', ''),
'port' => env('DB_PORT', '3306'),
],