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

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

    TLDR: You need to stop the server Ctrl + c and start again using php artisan serve


    Details:

    If you are using Laravel, and have started local dev server already by php artisan serve

    And after having above server already running, you change your database server related stuff in .env file. Like moving from MySQL to SQLite or something. You need to make sure that you stop above process i.e. Ctrcl C or anything which stop the process. And then restart Artisan Serve again i.e. y php artisan serve and refresh your browser and your issue related to database will be fixed. This is what worked for me for Laravel 5.3

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

    Got it! Log in as root and grant homestead@localhost the rights to everything.

    From your terminal:

    $ homestead ssh
    
    $ mysql -u root -p
    
    Enter password: secret
    
    mysql> grant all privileges on *.* to 'homestead'@'localhost' identified by 'secret';
    
    Query OK, 0 rows affected (0.00 sec)
    exit
    

    Now homesteads regular user has access to all of your tables, and as such, should be able to run things like migrations.

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

    In Windows PC Follow below.


    1. Access the Root folder of your application.

    2. Edit the .env file

    Edit the Highlighted and change the UserName and the password adn The database Name accordingly.

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

    In my case the error was "caused" by my Homestead / Vagrant configuration about which I forgot :) trying to run the migration just from command line.

    In case of using Homestead Vagrant Box environment you should run your migration from within your Homestead machine (after connecting to it using ssh: vagrant@192.168.10.10:22) then the access rights will be OK and will allow the migration to run.

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

    All you have to do is alter your .env file.

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

    In front of DB_DATABASE, write the name of the database and in front of DB_USERNAME, use root.

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

    just change these things in the .env file of your root folder.

    DB_DATABASE=your_db_name
    DB_USERNAME=your_db_user_name
    DB_PASSWORD='your_db_password'
    

    It worked for me.

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