我有一个与MAMP合作的Laravel项目。我试图用phpMyAdmin中的MySQL Server连接到我的数据库。 php artisan migrate
命令给出此错误:
Illuminate\Database\QueryException : SQLSTATE[HY000] [1045] Access denied for user 'root'@'localhost' (using password: YES) (SQL: select max(`batch`) as aggregate from `migrations`)
at /Applications/MAMP/htdocs/todoapp/vendor/laravel/framework/src/Illuminate/Database/Connection.php:664
660| // If an exception occurs when attempting to run a query, we'll format the error
661| // message to include the bindings with SQL, which will make this exception a
662| // lot more helpful to the developer instead of just the database's errors.
663| catch (Exception $e) {
> 664| throw new QueryException(
665| $query, $this->prepareBindings($bindings), $e
666| );
667| }
668|
Exception trace:
1 PDOException::("SQLSTATE[HY000] [1045] Access denied for user 'root'@'localhost' (using password: YES)")
/Applications/MAMP/htdocs/todoapp/vendor/laravel/framework/src/Illuminate/Database/Connectors/Connector.php:70
2 PDO::__construct("mysql:host=127.0.0.1;port=3306;dbname=tododb", "root", "root", [])
/Applications/MAMP/htdocs/todoapp/vendor/laravel/framework/src/Illuminate/Database/Connectors/Connector.php:70
Please use the argument -v to see more details.
我的环境。文件
DB_CONNECTION=mysql
DB_HOST=127.0.0.1
DB_PORT=3306
DB_DATABASE=tododb
DB_USERNAME=root
DB_PASSWORD=root
答案 0 :(得分:0)
请检查您的数据库连接凭据。您的用户“ root”似乎没有访问权限。如果您的用户凭据正确,请检查MySQL配置文件,查找允许的身份验证方法。