Artisan access denied for [email protected]


I have a problem with Laravel. My website has no problem accessing and performing operations on the database but when I try to run

php artisan migrate

I get the error:

  SQLSTATE[HY000] [1045] Access denied for user 'root'@'localhost' (using pas  
  sword: NO) (SQL: select * from information_schema.tables where table_schema  
   = wealthzoo and table_name = migrations)                                    

  SQLSTATE[HY000] [1045] Access denied for user 'root'@'localhost' (using pas  
  sword: NO) 

I have read every thread on the Internet about this error that I could find and none of them answered my question. It was always because people did not enter their database information correctly... However that is not my case since everything works fine in browser, I just cannot perform database related operations via the console.

On a thread that I read a while back someone recommended to create a folder in root directory named local (to match the app environment) and copy the database config file in it but I tried and that did not solve my problem.

I appreciate any help.

KhanhNguyen replied 1 week ago

Try to check out the .env file in your laravel application folder first The configuration is something like below


If you don't see any database configuration in the .env file, maybe you need to add connection information for your root user in this .env file

Verdi replied 1 week ago

@KhanhNguyen, Thank you.

As I stated in my original post, my database connection configuration is fine because I can run DB queries on my index page just fine, but if I try to do anything database related on my console like a artisan migrate or use artisan tinker to create entries to my database, I get the error I mentioned.

Luis Terrero replied 6 days ago

For some reason, when using Vagrant-Homestead dev environment you may need to change the DB port on your environment file if you want to work with the database from a command line (artisan or tinker)

Try replacing the DB port to 33060 in the .ENV file to run php artisan and change it back to 3306 when loading you app in a web browser.

Sign in to participate in this thread!

We'd like to thank these amazing companies for supporting us