开发者

Why is my MySQL server not recognizing foreign key relations?

开发者 https://www.devze.com 2023-03-29 08:59 出处:网络
Well I\'ve gotten 100+ answers to my questions on Stack Overflow, but it\'s time I finally registered and posted my first question!

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 开发者_JAVA百科tables are InnoDB. Google has not helped me with this and I could not find anything in the MySQL documentation.


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.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号