Access denied for user 'homestead'@'localhost' (using password: YES)

前端 未结 29 1718
爱一瞬间的悲伤
爱一瞬间的悲伤 2020-11-27 10:23

I\'m on a Mac OS Yosemite using Laravel 5.0.

While in my local environment, I run php artisan migrate I keep getting :

29条回答
  •  抹茶落季
    2020-11-27 10:28

    Two way to solve it

    First way (Not recommended)

    Open your database config file (laravel_root/config/database.php) & search for the below code block.

            'host'      => env('DB_HOST', 'localhost'),
            'database'  => env('DB_DATABASE', 'blog'),
            'username'  => env('DB_USERNAME', 'root'),
            'password'  => env('DB_PASSWORD', ''),
    

    Change the code block as below

            'host'      => 'yourHostName',
            'database'  => 'YourDatabastName',
            'username'  => 'YoutDatabaseUsername',
            'password'  => 'YourDatabasePassword',
    

    Second way (Recommended by Laravel)

    Check your Laravel root there have a file call .env if not exist, look for .env.example, copy/rename it as .env after that the file looks blow !

    APP_ENV=local
    APP_DEBUG=true
    APP_KEY=someRandomNumber
    
    DB_HOST=localhost
    DB_DATABASE=homestead
    DB_USERNAME=homestead
    DB_PASSWORD=secret
    
    CACHE_DRIVER=file
    SESSION_DRIVER=file
    QUEUE_DRIVER=sync
    
    MAIL_DRIVER=smtp
    MAIL_HOST=mailtrap.io
    MAIL_PORT=2525
    MAIL_USERNAME=null
    MAIL_PASSWORD=null
    

    Modify the below block as follow

    DB_HOST=yourHostName
    DB_DATABASE=yourDatabaseName
    DB_USERNAME=yourDatabaseUsername
    DB_PASSWORD=youPassword
    

    Now it will work fine.

提交回复
热议问题