Laravel 5 error SQLSTATE[HY000] [1045] Access denied for user 'homestead'@'localhost' (using password: YES)

前端 未结 24 1540
Happy的楠姐
Happy的楠姐 2021-02-03 19:23

I have installed Laravel 5 successfully and changed MySQL credentials in database.php file in config directory to \'

mysql\' => [
            \'driver\'           


        
相关标签:
24条回答
  • 2021-02-03 19:29

    in my case I wanted to connect to the database installed on windows that i used to access through workbench, so i replaced localhost with the ip address which i obtained by typing ipconfig on windows command prompt

    0 讨论(0)
  • 2021-02-03 19:31

    I was facing the same issue. Everything was fine but in

    bootstrap/cache/config.php

    always had the incomplete password. Upon digging further, realized that the password had '#' character in it and that was getting dropped. As '#' is used to mark a line as a comment.

    0 讨论(0)
  • 2021-02-03 19:32

    if you before use localhost and root your file be cached

    remove /bootstap/cache/config.php

    0 讨论(0)
  • 2021-02-03 19:33

    Open terminal on XAMPP > go to /opt/lampp/htdocs/project_name > run php artisan migrate

    .env file

    DB_CONNECTION=mysql
    DB_HOST=localhost
    DB_PORT=8080
    DB_DATABASE=database_name
    DB_USERNAME=root
    DB_PASSWORD=
    

    0 讨论(0)
  • 2021-02-03 19:34

    I spent hours on this :-( and finally, it was really easy to hack

    BEFORE

    DB_PASSWORD=#Root2020$
    

    UPDATED

    DB_PASSWORD="#Root2020$"
    

    I think the problem was # in the password, that's why I had to write my password into quotation marks.

    0 讨论(0)
  • 2021-02-03 19:37

    In my case, it was actually root user permission problem. My Laravel configurations were all perfect, but later I found that it was root user permission problem since my MySQL configs were somehow changed.

    • so i navigated to xampp folder > C:\xampp\mysql\bin
    • searched for my.ini file and opened it in editor then added added skip-grant-tables in following place:

    [mysqld] skip-grant-tables port=3306

    and it worked.

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