Skip to content
Advertisement

SQLSTATE[HY000] [1045] Access denied for user ‘root’@’localhost’

I make php artisan make:auth and tried to register as a new user then I get the error. I am using Xampp for MySQL and make a database name ‘pari’ and set user: root and password: root. After starting xampp apache and SQL server and PHP artisan serve on cmd I get the same error every time.

SQLSTATE[HY000] [1045] Access denied for user ‘root’@’localhost’ (using password: YES) (SQL: select count(*) as aggregate from users where email = avinashjk1620@gmail.com)

Step 1: I have changed .env file

JavaScript

and restart using php artisan serve , but again it gave that error.

Step 2: I have changed configdatabase.php to-

JavaScript

but it again gave that same error. Step 3: I tried

JavaScript

but again get same error.

Step 4: After removing password from phpmyadmin and .env and database.php I get new error-

JavaScript

How can i fixed this error Please help me.

Advertisement

Answer

Make sure your database was created using utf8mb4_unicode_ci collation. This should fix your 1071 error.

Alternatively you can add Schema::defaultStringLength(191); to your boot() method in appProvidersAppServiceProvider.php.

Edit: Make sure to add use IlluminateSupportFacadesSchema;.

User contributions licensed under: CC BY-SA
5 People found this is helpful
Advertisement