我无法在数据库中存储我的数据.我厌倦了得到这个本地主机错误



我无法在数据库中存储我的数据。我厌倦了得到这个本地主机错误更改密码和创建新数据库对我没有帮助。我尝试了许多可能的方法来解决这个问题

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>

。文件/p>

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
phpmyadmin的config.inc.php文件

<?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 */
?>

请对你的。env文件做如下修改。

.env

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

可能是你的密码应该是空的。

在phpmydamin中进入your_db>结帐用户名&密码

请填写mysql root用户密码。如果你忘记了,那么你必须重置

最新更新