MySQL 关闭外键检查
建表
对于插入新数据时,对于由于外键关联的主表缺少对应信息而导致子表插入数据失败的,可以暂时关闭外键检查。
1 | 关闭外键检查 |
导入时报错 Failed to open the referenced table
mysql导入报错信息
1 | [root@lw 20230323bak]# mysql -h 193.169.203.15 -u root -p -P 5958 apple < apple-20230323.sql |
解决方法:导入时关闭关键检查
1 | cat <(echo "SET FOREIGN_KEY_CHECKS=0;") apple-20230323.sql |mysql -h 193.169.203.15 -u root -p -P 5958 apple |


