php - 执行命令时 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。
预先感谢您的帮助。
解决方案
推荐阅读
- scala - Scala-Spark 开发人员是否必须在他的计算机上安装 Spark 和 Hadoop?
- r - 根据 col.names 中的 row.names 和条件汇总行 - R
- java - Java参数化方法解释
- android - Android 应用程序在 Pie 上出现 Textview 错误,但在 Oreo 上运行良好
- sql - 将表 1 的列 1 中的值替换为使用表 2 中的行中的值
- data-migration - 使用 Cloudendure 工具迁移 NFS(数据存储磁盘)
- python - 如何用((condition1 AND condition2)OR(condition2 AND condition3))构造一个sqlalchemy过滤器?
- google-analytics - Google Analytics Embed API 是否支持新的 GA4 属性?
- ruby-on-rails - Rails-复选框未变为真
- django - 测试密码保护页面django