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

前端 未结 24 1599
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:50

    The .env file should have same database name , username and password as in the mysql database and check whether all permissions are granted to the user for accessing the database or not. I solved my problem by adding the cpanel username in front of database name and username like jumbo_admingo and jumbo_user1 respectively where jumbo is my cpanel username and admingo is the database name i created in mysql and user1 is the user which has been provided the access to the database admingo. THIS SOLVED MY PROBLEM.

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

    Pls Update .env file

     DB_HOST=localhost
     DB_DATABASE=homestead
     DB_USERNAME=homestead
     DB_PASSWORD=secret
    

    After then restart server

    0 讨论(0)
  • 2021-02-03 19:52
    1. Edit the file .env in your laravel root directory. make looks as in below :

       DB_HOST=localhost
       DB_DATABASE=laravel
       DB_USERNAME=root
       DB_PASSWORD=your-root-pas
      
    2. Also create one database in phpmyadmin named, "laravel".

    3. Run below commands :

       php artisan cache:clear
       php artisan config:cache
       php artisan config:clear   
       php artisan migrate
      

    It worked for me, XAMPP with Apache and MySQL.

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

    This works to me:

    php artisan config:clear
    php artisan cache:clear
    php artisan config:cache
    

    Thanks.

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

    I Faced Same Problem what i did

    1. php artisan cache:clear
    2. php artisan config:cache

    but Same problem found than i run this artisan command

    php artisan view:clear

    Hope it will helpful.

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

    Reason is the old database credentials are cached /bootstap/cache/config.php

    In the .env file, I modified it as follow

     DB_HOST=localhost
     DB_DATABASE=homestead
     DB_USERNAME=homestead
     DB_PASSWORD=secret
    

    Then removed that file

    /bootstap/cache/config.php 
    

    If the issue still there you might try the following.

    php artisan config:clear php artisan cache:clear php artisan config:cache

    Exit vagrant by writing the exit command Then restart vargarnt/homestead config

    vagrant reload --provision
    

    Then opened vagrant again

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