4
votes

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 = [email protected])

Step 1: I have changed .env file

DB_CONNECTION=mysql
DB_HOST=127.0.0.1
DB_PORT=3306
DB_DATABASE=pari
DB_USERNAME=root
DB_PASSWORD=root

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

Step 2: I have changed config\database.php to-

 'mysql' => [
        'driver' => 'mysql',
        'host' => env('DB_HOST', '127.0.0.1'),
        'port' => env('DB_PORT', '3306'),
        'database' => env('DB_DATABASE', 'pari'),
        'username' => env('DB_USERNAME', 'root'),
        'password' => env('DB_PASSWORD', 'root'),
        'unix_socket' => env('DB_SOCKET', ''),
        'charset' => 'utf8mb4',
        'collation' => 'utf8mb4_unicode_ci',
        'prefix' => '',
        'strict' => true,
        'engine' => null,
    ],

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

  php artisan cache:clear 
  php artisan config:clear

but again get same error.

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

  SQLSTATE[42S02]: Base table or view not found: 1146 Table 'pari.users' doesn't exist (SQL: select count(*) as aggregate from `users` where `email` = [email protected])

How can i fixed this error Please help me.

5
remove you cache and restart the server - Rahul
do config:clear - Thamaraiselvam
I has remove cache and congifured but again getting same error - Avinash Kumar Yadav
does your sql has a password?? try logging in with the credentials you have provided, and remove the port once to check again - Exprator
yes password is root. I have changed it many times and tried but getting same error - Avinash Kumar Yadav

5 Answers

2
votes

Make sure all of your fields are set up correctly especially your password.

    $this->server = "localhost";
    $this->username = "root";
    $this->password = "";
    $this->dbName = "dbone";
    $this->charset = "utf8mb4";
1
votes

Do following things once you changed the credential

php artisan config:clear 
restart php artisan
1
votes

If there is still the problems with the connectivity to the server while on the Cpanel, I solve it by putting the password into a "" quotes and boom everything was responding correctly

DB_CONNECTION=mysql DB_HOST=127.0.0.1 DB_PORT=3306 DB_DATABASE=sppro DB_USERNAME=sppro DB_PASSWORD="sppro123#"

Done I was able to login into the files

0
votes

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 app\Providers\AppServiceProvider.php.

Edit: Make sure to add use Illuminate\Support\Facades\Schema;.

0
votes

Just only change .env file and DON'T change config/database.php file.

DB_CONNECTION=mysql
DB_HOST=127.0.0.1 or IP address
DB_PORT=3306
DB_DATABASE='your database name'
DB_USERNAME='your username'
DB_PASSWORD='your password'

it works for me!