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

前端 未结 24 1542
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:45

    If you are on MAMP

    Check your port number as well generally it is

    Host localhost

    Port 8889

    User root

    Password root

    Socket /Applications/MAMP/tmp/mysql/mysql.sock

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

    I had the same problem, so I realized that the .env file does not accept special characters, as my password has these characters, I added the password in the config/database.php file.

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

    Please update below file.

    vendor - .env - on line#7

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

    Instead of homestead user your database, username and password. This should work for you.

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

    It's working now. I had to restart server. Thanks

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

    You do not need to set credentials in database.php file. It is enough if you have credentials in .env

    If you are able to login to database directly then this password must work. It can be possible that you are having different environment than "local" which is defined in this file. Test is with "php artisan env"

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

    I came up with this too... then I solve it by putting the database information directly in " database.php " In your case, I would change the information like this

    mysql' => [
            'driver'    => 'mysql',
            'host'      => 'localhost',
            'database'  => 'wdcollect',
            'username'  => 'root',
            'password'  => '',
            'charset'   => 'utf8',
            'collation' => 'utf8_unicode_ci',
            'prefix'    => '',
            'strict'    => false,
        ],
    

    and don't forget to change your setting in XAMPP's config.inc

    ['auth_type'] = 'config';
    ['Servers'][$i]['user'] = 'root';
    ['Servers'][$i]['password'] = '';
    ['AllowNoPassword'] = true;
    
    0 讨论(0)
提交回复
热议问题