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

I have a Laravel project with MAMP. I tried to connect to my database with MySQL Server in phpMyAdmin. The php artisan migrate command gives this error:

  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.

my env. file

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

Please check your database connection credentials. It looks like your user "root" doesn't have access to it. If your user credentials is right, check the MySQL config file, looking for authentication method allowed.