简体   繁体   中英

Laravel 5 migration error 1045

I am having the following error: 在此输入图像描述

After following this guide: http://tutsnare.com/access-denied-for-user-homesteadlocalhost-laravel-5/

I changed my .env file in accordance with the guide but I'm still getting that error. Does anyone else know how to solve this? Also I am using a mac with MAMP on localhost. Thanks.

In your .env file you need to set the database config values to match your database configuration. With your current settings you are trying to login to the database as the root user without a password.

You say that you're using MAMP and the default MySQL password under MAMP is root , so your .env should have these database values.

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

Obviously, you'll also need to make sure there is a database named 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.

If you using MAMP you need to add some things.

In your .env add this..

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

If you changed your MAMP MySQL port change it here too.

Then in your database.php config add unix_socket and port ..

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM