首页 > 解决方案 > 执行命令时 laravel 出现问题:php artisan migrate

问题描述

运行命令“php artisan migration”时收到以下错误消息。

Illuminate\Database\QueryException  SQLSTATE[HY000] [2054] The server requested authentication method unknown to the client (SQL: create table `migrations` (`id` int unsigned not null auto_increment primary key, `migration` varchar(255) not null, `batch` int not null) default character set utf8mb4 collate 'utf8mb4_unicode_ci')

at vendor/laravel/framework/src/Illuminate/Database/Connection.php:671
     667▕         // If an exception occurs when attempting to run a query, we'll format the error
     668▕         // message to include the bindings with SQL, which will make this exception a
     669▕         // lot more helpful to the developer instead of just the database's errors.
     670▕         catch (Exception $e) {
   ➜ 671▕             throw new QueryException(
     672▕                 $query, $this->prepareBindings($bindings), $e
     673▕             );
     674▕         }
     675▕ 
 
       +29 vendor frames 
   30  artisan:37
      Illuminate\Foundation\Console\Kernel::handle(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))

我将主机数据库 localhost 更改为 127.0.0.1。我执行了命令“php artisan config:clear”。

这是我在 .env 文件中的配置:

DB_CONNECTION=mysql
DB_HOST=127.0.0.1.
DB_PORT=3306
DB_DATABASE=new_reservation
DB_USERNAME=root
DB_PASSWORD=

我在我的 Mac 上使用 MAMP。

我使用 PHP 版本 7.3.22。

预先感谢您的帮助。

标签: phplaravelmacos

解决方案


推荐阅读