There was an error copying the development environment from the library with the following error message:
mysql> show slave status\G;
Last_Errno: 1217
Last_Error: Error ‘Cannot delete or update a parent row: a foreign key constraint fails’ on query.
# perror 1217
MySQL error code 1217 (ER_ROW_IS_REFERENCED): Cannot delete or update a parent row: a foreign key constraint fails
mysql> show variables like ‘foreign_key_checks’;
+ — — — — — — — — — — — — — — — — — — — – + — — — — — — — +
| Variable_name Value | |
+ — — — — — — — — — — — — — — — — — — — – + — — — — — — — +
| foreign_key_checks | ON |
+ — — — — — — — — — — — — — — — — — — — – + — — — — — — — +
1 row in the set (0.00) sec)
mysql> show slave status\G;
Last_Errno: 1217
Last_Error: Error ‘Cannot delete or update a parent row: a foreign key constraint fails’ on query.
# perror 1217
MySQL error code 1217 (ER_ROW_IS_REFERENCED): Cannot delete or update a parent row: a foreign key constraint fails
mysql> show variables like ‘foreign_key_checks’;
+ — — — — — — — — — — — — — — — — — — — – + — — — — — — — +
| Variable_name Value | |
+ — — — — — — — — — — — — — — — — — — — – + — — — — — — — +
| foreign_key_checks | ON |
+ — — — — — — — — — — — — — — — — — — — – + — — — — — — — +
1 row in the set (0.00) sec)
Solution:
1. First stop slave, forbid foreign key constraint detection, start slave;
stop slave; set global foreign_key_checks =off; start slave;
2. Observe the normal synchronous replication by show Slave Status \G, start the foreign key constraint detection, and restart the replication.
set global foreign_key_checks =off; stop slave; start slave;
This operation is limited to the development environment and should be used with caution in the production environment.
Read More:
- MYSQL ERROR 1217 (23000): Cannot delete or update a parent row: a foreign key constraint fails
- Mysql error when deleting the table structure: Error Code: 1217. Cannot delete or update a parent row: a foreign key constraint fails
- Mysql error 1452 – Cannot add or update a child row: a foreign key constraint fails
- MySQL failed to add foreign key: SQL 1452 cannot add or update a child row:a foreign key constraint fails
- Solution to error 1452: cannot add or update a child row: a foreign key constraint failures in MySQL
- Matlab delete row or col to delete the row or column of the matrix
- MySQL error 1451 23000 foreign key exception handling
- MySQL:Foreign key fails with error Error Code: 1452.
- MySql ERROR CODE:1215 Cannot add the foreign key constraint
- MySQL failed to add foreign key error 1452
- About MySQL error: subquery returns more than 1 row
- mysql5.7.26:[ERR] 1118 – Row size too large (> 8126)
- Global lock, table lock and row lock in MySQL
- mysql Error Code: 1022. Can’t write; duplicate key in table `xxx`
- The total row of the Element table entry page is not displayed
- Failed to add the foreign key constraint. Missing index for constraint ‘stu_ibfk_1’ in the reference
- Syntax error or access violation: 1055 Expression #1 of SELECT list is not in GROUP BY clause and co
- [latex] latex adjust row spacing
- 1822 – Failed to add the foreign key constraint. Missing index for constraint ‘tb_emp_ibfk_1’ in the
- The togglerowexpansion method of the table of element UI expands the specified row