首页 > 解决方案 > php artisan 迁移的问题

问题描述

我对 php artisan 迁移有疑问。我以 root 身份使用,响应如下:

  Illuminate\Database\QueryException 

  SQLSTATE[HY000] [2002] No such file or directory (SQL: select * from information_schema.tables where table_schema = cms and table_name = migrations and table_type = 'BASE TABLE')

我必须做些什么来解决这个问题?

编辑 1

我检查我的 .env 文件并配置它

当我使用:

php artisan config:clear
php artisan migrate:instal

它给了我要求:

   Illuminate\Database\QueryException 

  SQLSTATE[HY000] [2002] No such file or directory (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')

这是我的 .env 文件

DB_CONNECTION=mysql
DB_HOST=localhost
DB_PORT=3306
DB_DATABASE=cms
DB_USERNAME=root
DB_PASSWORD=gaMoJVnwXp

我认为这是我没有进行表迁移的问题,但它也没有工作。我也尝试在 php.ini 中启用 pdo 文件,但它也没有用。当我进行 php artisan 迁移时,我必须有空数据库或名为迁移的表?

编辑 2 好的,我几乎完成了。它认为我有 sql 配置问题。我重新安装了 mysql 服务器,现在我可以使用 mysql 命令了。现在我遇到了 php artisan migrate 的问题——我没有任何回溯,但看起来它正在连续加载。你有什么想法?

标签: phpmysqllaravel

解决方案


请检查并正确配置您的 .env!

DB_CONNECTION=mysql
DB_HOST=127.0.0.1
DB_PORT=3306
DB_DATABASE=db
DB_USERNAME=root
DB_PASSWORD=123456

如果还是不行试试这个

php artisan config:clear
php artisan migrate:install

推荐阅读