【问题标题】:Illuminate\Database\QueryException : SQLSTATE[HY000]: General error: 1813 Tablespace for tableIlluminate\Database\QueryException : SQLSTATE[HY000]: 一般错误: 1813 Tablespace for table
【发布时间】:2018-10-02 06:17:24
【问题描述】:

我正在使用 Laravel 5.6

我尝试为我的项目迁移采购表
当我尝试迁移时,它显示表空间错误。

一般错误:1813 表“jshop.purchases”的表空间存在。请在 IMPORT 之前丢弃表空间。

迁移下面的代码:

Schema::create('purchases', function (Blueprint $table) {
        $table->increments('id');
        $table->integer("product_price");
        $table->integer("product_qty");
        $table->unsignedInteger('invoice_id');
        $table->unsignedInteger('product_id');
        $table->unsignedInteger('weight_id');
        $table->timestamps();
        $table->foreign("invoice_id")->references('id')->on('invoices');
        $table->foreign("product_id")->references('id')->on('products');
        $table->foreign("weight_id")->references('id')->on('weights');
    });

invoice,products,weights 表在我的数据库中有效。

错误信息图片如下: Migration Error image Link 如何解决?

Full Migration Code Image

【问题讨论】:

  • 你能分享完整的迁移代码吗?
  • @sanduniYW 先生,当我试图放置所有代码时,它会警告我代码长度。这就是为什么我在i.stack.imgur.com/yeH83.jpg下方分享了图片链接,请打开这个。
  • kk..谢谢。我在下面添加答案。请尝试一下。
  • 请将问题中的相关代码作为文本而不是图像。如果图片链接断开,这个问题就会变得不那么有用......

标签: php mysql laravel laravel-5.6


【解决方案1】:

试试这个:

php artisan migrate:refresh

如果没有解决这个错误 试试这个:

转到mysql/data/database_name /tablename.ibd file 并手动删除它。 在此之后尝试你的命令php artisan migrate

【讨论】:

  • 先生......仍然面临这个问题。 :(
  • 你使用 xampp 还是 wamp?
  • xampp 在 windows 10 操作系统中
  • 尝试以上解决方案
  • 先生,它不起作用......当我创建具有不同名称的新数据库并迁移它时。现在它的工作。非常感谢您的帮助先生...您的建议非常好
【解决方案2】:

删除数据库并创建一个新的。

【讨论】:

  • 虽然这个建议不是解决问题的最优雅的解决方案,但在某些情况下,它会起作用。
  • 听起来像:“只需重新安装 Windows”))
【解决方案3】:

找到您的数据库所在的位置并删除该表。然后运行 ​​PHP artisan migrate 这对我有用

【讨论】:

    猜你喜欢
    • 2019-03-24
    • 1970-01-01
    • 2017-09-28
    • 2019-06-05
    • 1970-01-01
    • 2021-01-05
    • 2019-05-21
    • 1970-01-01
    • 2020-09-30
    相关资源
    最近更新 更多