php artisan migrate:使用mamp:拒绝访问用户'root'@'localhost'

问题描述 投票:-1回答:1

我和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
php laravel mamp
1个回答
0
投票

请检查您的数据库连接凭据。看起来您的用户“root”无法访问它。如果您的用户凭据是正确的,请检查MySQL配置文件,查找允许的身份验证方法。

© www.soinside.com 2019 - 2024. All rights reserved.