skip to Main Content

I cannot store my data in database. I am tired of getting this localhost error
Changing passwords and creating new databases did not help for me. I tried many possible ways solving this

Error I got in terminal

PS C:ProgrammingLaravelDailyTaskApp> php artisan migrate
   IlluminateDatabaseQueryException 
  SQLSTATE[HY000] [1045] Access denied for user 'root'@'localhost' (using password: YES) (SQL: select * from information_schema.tables where table_schema = daily_task_app and table_name = migrations and table_type = 'BASE TABLE')
  at C:ProgrammingLaravelDailyTaskAppvendorlaravelframeworksrcIlluminateDatabaseConnection.php:692
    688▕         // If an exception occurs when attempting to run a query, we'll format the error
    689▕         // message to include the bindings with SQL, which will make this exception a
    690▕         // lot more helpful to the developer instead of just the database's errors.
    691▕         catch (Exception $e) {
  ➜ 692▕             throw new QueryException(
    693▕                 $query, $this->prepareBindings($bindings), $e
    694▕             );
    695▕         }
    696▕     }
  1   C:ProgrammingLaravelDailyTaskAppvendorlaravelframeworksrcIlluminateDatabaseConnectorsConnector.php:70
      PDOException::("SQLSTATE[HY000] [1045] Access denied for user 'root'@'localhost' (using password: YES)")        
  2   C:ProgrammingLaravelDailyTaskAppvendorlaravelframeworksrcIlluminateDatabaseConnectorsConnector.php:70
      PDO::__construct("mysql:host=127.0.0.1;port=3306;dbname=daily_task_app", "root", "root", [])
PS C:ProgrammingLaravelDailyTaskApp>

.env file

APP_NAME=Laravel
APP_ENV=local
APP_KEY=base64:JB0Pw8lHFyh0yjhyd4fYfY3W1ElXRQ52Xopcv0TWEkc=
APP_DEBUG=true
APP_URL=http://localhost

LOG_CHANNEL=stack
LOG_LEVEL=debug

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

BROADCAST_DRIVER=log
CACHE_DRIVER=file
FILESYSTEM_DRIVER=local
QUEUE_CONNECTION=sync
SESSION_DRIVER=file
SESSION_LIFETIME=120

config.inc.php file of phpmyadmin

<?php


/* Authentication type and info */
$cfg['Servers'][$i]['auth_type'] = 'config';
$cfg['Servers'][$i]['user'] = 'root';
$cfg['Servers'][$i]['password'] = 'root';
$cfg['Servers'][$i]['extension'] = 'mysqli';
$cfg['Servers'][$i]['AllowNoPassword'] = true;
$cfg['Lang'] = '';

/* Bind to the localhost ipv4 address and tcp */
$cfg['Servers'][$i]['host'] = 'localhost';
$cfg['Servers'][$i]['connect_type'] = 'tcp';

/* User for advanced features */
$cfg['Servers'] [$i]['controluser'] = 'pma'; 
$cfg['Servers'][$i]['controlpass'] = '';

/* Advanced phpMyAdmin features */

?>

2

Answers


  1. You should fill password of mysql root user.
    if you forgot it then you must reset it

    Login or Signup to reply.
  2. Please, do following changes to your .env file.

    .env

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

    may be your password should be blank.

    In phpmydamin go to your_db > privalages to checkout username & password

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search