php - 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 的问题——我没有任何回溯,但看起来它正在连续加载。你有什么想法?
解决方案
请检查并正确配置您的 .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
推荐阅读
- c# - HttpClient.PostAsync 返回 System.IO.Stream 作为属性
- python - 用于回填的气流 DAG
- python - 如何使用 Python 删除存储在 Pickle 文件中的对象
- php - 使用 Doctrine2 按 Not Null 分组
- gcc - asm 指令“jmpq *0xa48201(%rip)”到底在做什么?
- c - Pthreads而不是共享变量
- spring - Kotlin - 如何将 BodyToMono 与泛型和嵌套类一起使用 WebFlux
- java - Bazel 在resin/raspberry-pi3-debian 上从头开始构建错误
- javascript - IOS页面间传递数据
- python - 尝试在 celery 任务文件中导入模型时尚未加载应用程序