已经导出了数据库文件:DataBack.sql.  
可是在相同的环境下的其他机器上执行导入数据库语句:  
mysql  -u  root  DDT  <  DataBack.sql。  
就会出现错误:#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  '&#65279;--  MySQL  dump  10.9  
--  
--  Host:  localhost        Database:  DDT  
 
我导出的Mysql数据库表中有数据,并且有些表之间互相引用。  是不是在顺序执行导入的sql语句时出现错误了,如我备份的数据库.sql文件其中的一个表的创建:  
CREATE  TABLE  `board_class`  (  
   `BOARD_CLASS_ID`  smallint(6)  NOT  NULL  default  '0',  
   `BOARD_CLASS_NAME`  varchar(100)  NOT  NULL  default  '',  
   `BOARD_CLASS_NAME_E`  varchar(100)  default  NULL,  
   `BOARD_GROUP_ID`  smallint(6)  NOT  NULL  default  '0',  
   `ORDER_NO`  smallint(6)  default  NULL,  
   PRIMARY  KEY    (`BOARD_CLASS_ID`),  
   KEY  `BOARD_GROUP_ID`  (`BOARD_GROUP_ID`),  
   CONSTRAINT  `board_class_ibfk_1`  FOREIGN  KEY  (`BOARD_GROUP_ID`)  REFERENCES  `board_group`  (`BOARD_GROUP_ID`)  
)  ENGINE=InnoDB  DEFAULT  CHARSET=utf8;  
 
那要是这样的话,应该怎样导入呢?  

解决方案 »

  1.   

    cut the foreign keys, constraints and triggersadd them at the end of create tables commands before insert data.
      

  2.   

    感谢!感谢!
    那去掉了foreign keys, constraints and triggers之后,应该再怎样加上呢?请指教
      

  3.   

    ALTER [IGNORE] TABLE tbl_name
        alter_specification [, alter_specification] ...alter_specification:
        ADD [COLUMN] column_definition [FIRST | AFTER col_name ]
      | ADD [COLUMN] (column_definition,...)
      | ADD INDEX [index_name] [index_type] (index_col_name,...)
      | ADD [CONSTRAINT [symbol]]
            PRIMARY KEY [index_type] (index_col_name,...)
      | ADD [CONSTRAINT [symbol]]
            UNIQUE [index_name] [index_type] (index_col_name,...)
      | ADD [FULLTEXT|SPATIAL] [index_name] (index_col_name,...)
      | ADD [CONSTRAINT [symbol]]
            FOREIGN KEY [index_name] (index_col_name,...)
            [reference_definition]