为什么我的 MySQL 服务器无法识别外键关系?

发布于 2024-11-30 15:47:36 字数 516 浏览 1 评论 0原文

好吧,我在 Stack Overflow 上得到了 100 多个问题的答案,但现在是我终于注册并发布我的第一个问题的时候了!

好吧,我有一个程序用户表和附加到该表的 11 个表,具有 1:1 和 1:M 关系。大多数外键设置为ON UPDATE CASCADE ON DELETE RESTRICT。如果我删除中心表,它允许我这样做,尽管外键应该就位。当我以前处理过关系数据库时,我会收到以下错误消息:

#1217 - Cannot delete or update a parent row: a foreign key constraint fails
#1452 - Cannot add or update a child row: a foreign key constraint fails

现在请注意,这是我实际上想要错误消息的一次。我想要关系数据库的功能,并且我的所有表都是 InnoDB。 Google 没有帮助我解决这个问题,而且我在 MySQL 文档中找不到任何内容。

Well I've gotten 100+ answers to my questions on Stack Overflow, but it's time I finally registered and posted my first question!

Alright, I have a table for the users of my program and 11 tables attached to this table with 1:1 and 1:M relationships. Most of the foreign keys are set to ON UPDATE CASCADE ON DELETE RESTRICT. If I delete the center table, it allows me to, despite the foreign keys that should be in place. When I have dealt with relational databases before, I would receive these error messages:

#1217 - Cannot delete or update a parent row: a foreign key constraint fails
#1452 - Cannot add or update a child row: a foreign key constraint fails

Now mind you, this is one time I actually want error messages. I want the functionality of a relational database and all of my tables are InnoDB. Google has not helped me with this and I could not find anything in the MySQL documentation.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

谁的新欢旧爱 2024-12-07 15:47:36

MySQL 论坛上的这篇文章很接近,但没有准确地详细说明需要采取哪些措施来解决此问题。基本上:

service mysqld stop
cd /var/lib/mysql
mkdir old
mv ib* old
vim /etc/my.cnf
servie mysqld start

对于 vim,请确保 innodb_buffer_pool_size、innodb_log_file_size 和 innodb_log_buffer_size 设置正确。 MySQL 论坛上的另一篇文章有一点配置错误,即 innodb_log_file_size需要是 innodb_buffer_pool_size 的 25%,所以我分别为这三个设置了 16M、4M 和 8M。

This post on the MySQL forums came close but did not detail exactly what needs to be done to fix this. Basically:

service mysqld stop
cd /var/lib/mysql
mkdir old
mv ib* old
vim /etc/my.cnf
servie mysqld start

For the vim, make sure innodb_buffer_pool_size, innodb_log_file_size, and innodb_log_buffer_size are set properly. Another post on the MySQL forums had a bit of misconfiguration, namely that innodb_log_file_size needs to be 25% of innodb_buffer_pool_size, so I have 16M, 4M, and 8M for these three respectively.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文