Magento 2 SQLSTATE [HY000]:常规错误:1823无法添加外键约束 [英] Magento 2 SQLSTATE[HY000]: General error: 1823 Failed to add the foreign key constraint

查看:77
本文介绍了Magento 2 SQLSTATE [HY000]:常规错误:1823无法添加外键约束的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,我的Magento 2商店出现错误.例如API请求失败,Swagger提供500,样式表和JS文件无法加载等.

Hello guys I was getting errors with my Magento 2 Store.. Such as Failed API Requests, Swagger gives 500, Stylesheets and JS files won't load etc..

最后,我发现最好的解决方案是使用新鲜的主题文件创建全新的Magento安装,然后从文件中复制 pub/media 并使用维护模式删除所有以 customers_为前缀的表 catalog _ sales _ eav _

Finally I found that the best solution to create a fresh Magento installation with fresh theme files and just copy pub/media from files and go with maintenance mode to drop all tables prefixed with customers_ , catalog_ , sales_ and eav_

此步骤使我的新商店工作得很好,但是出现了新的错误..我无法运行 setup:upgrade ,它显示一条消息:

This step made my new store works very good but I got new kind of errors .. I can't run setup:upgrade it shows a message with:

[PDOException] SQLSTATE[HY000]: General error: 1823 Failed to add the foreign key constraint 'porosec_pororom/CAT_CTGR_PRD_CTGR_ID_CAT_CTGR_ENTT_ENTT_ID' to system tables

当我运行 php -f bin/magento setup:db-schema:upgrade

上一条消息发生的命令

当我运行 composer update 时,它也会更新许多依赖关系,但需要运行 setup:upgrade .

also when I run composer update it updates many of dependencies but it require to run setup:upgrade.

Swagger错误500

{"0":请升级您的数据库:运行\" bin/magento setup:upgrade \来自Magento根目录.\ n以下模块是已过时:\ nKlarna_Core数据:当前版本-4.1.5,必需版本-4.2.3 \ nKlarna_Ordermanagement数据:当前版本-4.1.2,必需版本-4.1.3," 1:"#0/home/porosec/public_html/test/vendor/magento/framework/Interception/Interceptor.php(121):Magento \ Framework \ Module \ Plugin \ DbStatusValidator-> beforeDispatch(Object(Magento \ Framework \ App \ FrontController \ Interceptor),对象(Magento \ Framework \ App \ Request \ Http))\ n#1/home/porosec/public_html/test/vendor/magento/module-page-cache/Model/App/FrontController/BuiltinPlugin.php(73):Magento \ Framework \ App \ FrontController \ Interceptor-> Magento \ Framework \ Interception \ {closure}(对象(Magento \ Framework \ App \ Request \ Http))\ n#2/home/porosec/public_html/test/vendor/magento/framework/Interception/Interceptor.php(135):Magento \ PageCache \ Model \ App \ FrontController \ BuiltinPlugin-> aroundDispatch(Object(Magento \ Framework \ App \ FrontController \ Interceptor),对象(关闭),对象(Magento \ Framework \ App \ Request \ Http))\ n#3/home/porosec/public_html/test/vendor/magento/framework/Interception/Interceptor.php(153):Magento \ Framework \ App \ FrontController \ Interceptor-> Magento \ Framework \ Interception \ {closure}(对象(Magento \ Framework \ App \ Request \ Http))\ n#4/home/porosec/public_html/test/generated/code/Magento/Framework/App/FrontController/Interceptor.php(26):Magento \ Framework \ App \ FrontController \ Interceptor-> ___ callPlugins('dispatch',阵列,阵列)\ n#5/home/porosec/public_html/test/vendor/magento/framework/App/Http.php(135):Magento \ Framework \ App \ FrontController \ Interceptor-> dispatch(对象(Magento \ Framework \ App \ Request \ Http))\ n#6/home/porosec/public_html/test/generated/code/Magento/Framework/App/Http/Interceptor.php(24):Magento \ Framework \ App \ Http-> launch()\ n#7/home/porosec/public_html/test/vendor/magento/framework/App/Bootstrap.php(256):Magento \ Framework \ App \ Http \ Interceptor-> launch()\ n#8/home/porosec/public_html/test/index.php(39):Magento \ Framework \ App \ Bootstrap-> run(Object(Magento \ Framework \ App \ Http \ Interceptor))\ n#9{main}," url:"/test/swagger," script_name:"/test/index.php}

{"0":"Please upgrade your database: Run \"bin/magento setup:upgrade\" from the Magento root directory.\nThe following modules are outdated:\nKlarna_Core data: current version - 4.1.5, required version - 4.2.3\nKlarna_Ordermanagement data: current version - 4.1.2, required version - 4.1.3","1":"#0 /home/porosec/public_html/test/vendor/magento/framework/Interception/Interceptor.php(121): Magento\Framework\Module\Plugin\DbStatusValidator->beforeDispatch(Object(Magento\Framework\App\FrontController\Interceptor), Object(Magento\Framework\App\Request\Http))\n#1 /home/porosec/public_html/test/vendor/magento/module-page-cache/Model/App/FrontController/BuiltinPlugin.php(73): Magento\Framework\App\FrontController\Interceptor->Magento\Framework\Interception\{closure}(Object(Magento\Framework\App\Request\Http))\n#2 /home/porosec/public_html/test/vendor/magento/framework/Interception/Interceptor.php(135): Magento\PageCache\Model\App\FrontController\BuiltinPlugin->aroundDispatch(Object(Magento\Framework\App\FrontController\Interceptor), Object(Closure), Object(Magento\Framework\App\Request\Http))\n#3 /home/porosec/public_html/test/vendor/magento/framework/Interception/Interceptor.php(153): Magento\Framework\App\FrontController\Interceptor->Magento\Framework\Interception\{closure}(Object(Magento\Framework\App\Request\Http))\n#4 /home/porosec/public_html/test/generated/code/Magento/Framework/App/FrontController/Interceptor.php(26): Magento\Framework\App\FrontController\Interceptor->___callPlugins('dispatch', Array, Array)\n#5 /home/porosec/public_html/test/vendor/magento/framework/App/Http.php(135): Magento\Framework\App\FrontController\Interceptor->dispatch(Object(Magento\Framework\App\Request\Http))\n#6 /home/porosec/public_html/test/generated/code/Magento/Framework/App/Http/Interceptor.php(24): Magento\Framework\App\Http->launch()\n#7 /home/porosec/public_html/test/vendor/magento/framework/App/Bootstrap.php(256): Magento\Framework\App\Http\Interceptor->launch()\n#8 /home/porosec/public_html/test/index.php(39): Magento\Framework\App\Bootstrap->run(Object(Magento\Framework\App\Http\Interceptor))\n#9 {main}","url":"/test/swagger","script_name":"/test/index.php"}

Swagger错误日志

这也是我在管理控制台中看到的内容

Also here's what I got in admin dashboard

管理面板错误

[2018-06-04 23:18:09] main.CRITICAL: Report ID: webapi-5b15c8b17792e; Message: Class "array" does not exist. Please note that namespace must be specified. {"exception":"[object] (Exception(code: 0): Report ID: webapi-5b15c8b17792e; Message: Class \"array\" does not exist. Please note that namespace must be specified. at /home/porosec/public_html/test/vendor/magento/framework/Webapi/ErrorProcessor.php:205, LogicException(code: 0): Class \"array\" does not exist. Please note that namespace must be specified. at /home/porosec/public_html/test/vendor/magento/framework/Reflection/TypeProcessor.php:139)"} []

管理面板错误日志

推荐答案

如果您已经备份了同一张表,并且外键约束与bkp表相同,并且当前表mysql将抛出异常,则更改约束名称或删除现有约束.

if you have taken the backup of same table and if foreign key constraint is same as bkp table and current table mysql will throw exception, so change the constraint name or delete the existing constraint.

约束名称不能相同.

这篇关于Magento 2 SQLSTATE [HY000]:常规错误:1823无法添加外键约束的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆