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

前端 未结 29 1505
爱一瞬间的悲伤
爱一瞬间的悲伤 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:31

    i using laravel 5.* i figure i have a file call .env in the root of the project that look something like this:

    APP_ENV=local
    APP_DEBUG=true
    APP_KEY=SomeRandomString
    
    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
    MAIL_ENCRYPTION=null
    

    And that was over writing the bd configuration so you can wheather deleted those config vars so laravel take the configuration under /config or set up your configuration here.

    I did the second and it works for me :)

    0 讨论(0)
  • 2020-11-27 10:31

    i have find solution

    1. Go to your application root directory and open .env file (In ubuntu may be it’s hidden so press ctrl+h to show hidden files) in your editor and change database configuration setting. then save your .env file

    2. then restart your apache server/web server. and refresh your page and you have done

    3. If still issue try to run below command to clear the old configuration cache file.

    This worked for me gl ...

    0 讨论(0)
  • 2020-11-27 10:33

    You have to run the $ php artisan migrate command from within Homestead, not your Mac.

    0 讨论(0)
  • 2020-11-27 10:34

    If you are using the PHP's default web server (e.g. php artisan serve) you need to restart your server after changing your .env file values.

    0 讨论(0)
  • 2020-11-27 10:34

    Sometime in the future. Try to clear your config first

    php artisan config:clear. 
    

    Close all the terminal /cmd windows and then restart terminal/CMD and this should get rid of the error message. See if it works.

    0 讨论(0)
  • 2020-11-27 10:35

    When you install Homestead, this creates a default "homestead" database in the VM. You should SSH into the VM homestead ssh and run your migrations from there. If you are working locally with no VM, you'll need to create your database manually. By default, the database should be called homestead, the username is homestead and the password is secret.

    check this thread on laracasts or this blog post for more details


    if you are getting

    [PDOException] SQLSTATE[HY000] [2002] No such file or directory
    

    try changing "host" in the /app/config/database.php file from "localhost" to "127.0.0.1" . you can find more details and other fixes here on this thread.

    Also check whether you have specified the correct unix_socket . check this thread .

    0 讨论(0)
提交回复
热议问题