0

I try to run xampp on window 7. My php version is php 7.3.2. After run composer install, I run php artisan migrate.

My error is:

SQLSTATE[HY000] [1044] Access denied for user ''@'localhost' to database 'inventory' (SQL: select * from information _schema.tables where table_schema = inventory and table_name = migrations)

and

SQLSTATE[HY000] [1044] Access denied for user ''@'localhost' to database 'inventory'

Shadow
  • 33,525
  • 10
  • 51
  • 64
irham dollah
  • 169
  • 13
  • Did you confirm that you the user that is in your .env have permission in mysql ? – Muhammad Faran Ali Nov 26 '19 at 07:15
  • It seems that your database credentials are not correct/complete. The user is empty. Check the `.env` file and make sure there is a user name for connecting to database. – Rouhollah Mazarei Nov 26 '19 at 07:15
  • Check your .env file. If your configs are correct, check xampp running correctly. – fedev Nov 26 '19 at 07:26
  • Does this answer your question? [PDOException (1044) SQLSTATE\[HY000\] \[1044\] Access denied for user ''@'localhost' to database 'forge'](https://stackoverflow.com/questions/29986626/pdoexception-1044-sqlstatehy000-1044-access-denied-for-user-localhost) – Karoid Nov 26 '19 at 08:13
  • I got it. Thank you – irham dollah Nov 27 '19 at 10:00

2 Answers2

0

You forgot to set DB_USERNAME= in the .env file, so you're getting this error:

SQLSTATE[HY000] [1044] Access denied for user ''@'localhost' to database 'inventory'

Open the .env file and edit it. Just set up correct DB credentials:

DB_USERNAME=         //Your Database Username           

DB_USERNAME should be set to root if you do not have a default username in the installation time

After changes of .env enter this command in your terminal for clear cache:php artisan config:cache


NOTE: If you're still getting error

Check your database configuration with tinker.

php artisan tinker

then write this will give you whole configuration check is it right or not.

>>config('database')
Dilip Hirapara
  • 14,810
  • 3
  • 27
  • 49
0

Specify your DB configuration as per below: also make sure you have created a database.

DB_DATABASE= db_name
DB_USERNAME= user_name
DB_PASSWORD= password

Make sure your xampp is running.

Then after editing the .env file run below command.

php artisan config:clear

and then run,

php artisan migrate
Prathamesh Doke
  • 797
  • 2
  • 16
  • 38