记录一次Navicat导入sql文件报错的问题

    科技2025-08-15  4

    Navicat版本:Navicat Premium 12 数据库:mysql 5.6.36 问题描述: 项目需要省市区三级联动,导入表时报错具体错误如下:

    [SQL] Query 省市区三级联动 start [ERR] 1064 - You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '​-- ---------------------------- -- Table structure for province -- ----------' at line 1 [ERR] ​-- ---------------------------- -- Table structure for province -- ----------------------------

    解决方案: 在数据库文件开头部分加入:

    SET foreign_key_checks = 0; // 先设置外键约束检查关闭 SET NAMES utf8mb4;//设置字符集

    然后删除报错的注释部分:

    问题解决:

    最后附上我的sql文件,省市区三级联动表,有需要的朋友自行取用: 链接:https://pan.baidu.com/s/1yWk1a82yUkVtnaAIbGewQg 提取码:zv30

    Processed: 0.025, SQL: 9