Access denied for user 'homestead@localhost' .. in laravel 5

后端 未结 11 2193
甜味超标
甜味超标 2021-02-10 10:01

I use the command php artisan migrate to migrate my db in laravel 5 .. it gives me an error:

exception \'PDOException\' with message \'SQLSTATE[HY000] [10

相关标签:
11条回答
  • 2021-02-10 10:12

    In your .env file change DB_PORT from

    DB_PORT=3306
    

    to

    DB_PORT=33060
    

    refrence to https://laravel.com/docs/5.4/homestead#connecting-to-databases

    becarefull about last zero

    0 讨论(0)
  • 2021-02-10 10:17

    Once you changed your .env file then you must restart the server.

    In laravel in command prompt, type:

    php artisan serve
    
    0 讨论(0)
  • 2021-02-10 10:18

    Run the following command:

    php artisan cache:clear
    php artisan config:cache
    
    0 讨论(0)
  • 2021-02-10 10:21

    in your database.php file, take off 'DB_DATABASE' 'DB_USERNAME' 'DB_PASSWORD'

    and replace with your database name, username and password

    this will work fine for u.

    0 讨论(0)
  • 2021-02-10 10:22

    In your Laravel .env file, alter the variables accordingly to match your desired settings.

    If you're using something like XAMMP or EasyPHP with a mysql db, perhaps use the following setup

     DB_HOST=localhost
     DB_DATABASE=mysql
     DB_USERNAME=root
     DB_PASSWORD=''
    
    0 讨论(0)
  • 2021-02-10 10:23

    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)
提交回复
热议问题