Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Laravel 5 migration error 1045

I am having the following error: enter image description here

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.

like image 797
John123 Avatar asked Dec 19 '25 14:12

John123


2 Answers

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.

like image 107
BrokenBinary Avatar answered Dec 22 '25 04:12

BrokenBinary


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'),
],
like image 41
Nick Avatar answered Dec 22 '25 04:12

Nick



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!