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

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

    If you have an error returning something like PDOException in Connector.php line 55: SQLSTATE[HY000] [1049] Unknown database 'laravelu' is due to you are changing your batabase config as DB_DATABASE=laravelu. So for now you either:

    1. Change the DB_DATABASE=[yourdatabase] or
    2. create a database called laravelu in your phpmyadmin

    this should be able to solve it

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

    in my case (laravel 5+) i had to wrap my password in single quotation marks and clear config cache:

    DB_CONNECTION=mysql
    DB_HOST=localhost
    DB_PORT=3306
    DB_DATABASE=database_name
    DB_USERNAME=user_name
    DB_PASSWORD='password'
    

    and then run:

    php artisan config:clear
    
    0 讨论(0)
  • 2020-11-27 10:44

    Log into MYSQL - use the mysql database.

    Select * from User;

    Make sure that your HOST column is correct. It should be the host that you are connecting from (your application server) be it IP address, or DNS name. Also '%' will work (meaning wildcard) but will not be secure.

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

    Check MySQL UNIX Socket

    Find unix_socket location using MySQL

    mysql -u homestead -p

    mysql> show variables like '%sock%';
    +-----------------------------------------+-----------------------------+
    | Variable_name                           | Value                       |
    +-----------------------------------------+-----------------------------+
    | performance_schema_max_socket_classes   | 10                          |
    | performance_schema_max_socket_instances | 322                         |
    | socket                                  | /var/run/mysqld/mysqld.sock |
    +-----------------------------------------+-----------------------------+
    3 rows in set (0.00 sec)
    

    Then I go to config/database.php

    I update this line : 'unix_socket' => '/tmp/mysql.sock',

    to : 'unix_socket' => '/var/run/mysqld/mysqld.sock',

    That's it. It works for my as my 4th try.I hope these steps help someone. :D

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

    I had the same issue and in the end It turned out that I just had to restart the server and start again

    Ctrl + c then

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