Error Code: 1064 – You have an error in your SQ...

Error Code: 1064 – You have an error in your SQL syntax解决几个方法

mysql备份还原时,查看错误日志,内容如下:
Error Code: 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 ‘USING BTREE

分析原因可能使用了高版本的SQL语句在低版本中导入,

最后在网上查找整理出以下几个解决方法:
1,升级MYSQL数据库到相应的对应版本(这个可能很麻烦)

2,程序代码ENGINE=MyISAM DEFAULT CHARSET=latin1或者程序代码ENGINE=InnoDB DEFAULTCHARSET=latin1
全部替换为程序代码
ENGINE=MyISAM
可以将SQL文件分批COPY建立SQL文件,然后 分批导入.
这样方便查找具体是那个地方出错,如:
ERROR 1074 at line 1802: Too big column length for column ‘Cjieshao’ (max = 255
. Use BLOB instead
说明文件字符长度超过当前版本. MYSQL4.0只支持255个,当高版本如MYSQL5.0导入时候就要注意修改长度为255再导入就会正常
ERROR 1064 at line 3034: You have an error in your SQL syntax.   Check the manua
that corresponds to your MySQL server version for the right syntax to use near
‘collate utf8_swedish_ci default NULL,
   PRIMARY KEY   (`sshyid`)
解决方法: 去掉 ‘collate utf8_swedish_ci 就正常
.sql -u root -p密码

3,导出文件中的源码:
  PRIMARY KEY (`row_id`) USING BTREE,
  UNIQUE KEY `columnAindex` (`columnA`),
  KEY `columnBindex` (`columnB`) USING HASH,
  KEY `columnCindex` (`columnC`) USING BTREE,

全部替换为:
  PRIMARY KEY USING BTREE  (`row_id`),
  UNIQUE KEY `columnAindex` (`columnA`),
  KEY `columnBindex` USING HASH (`columnB`),
  KEY `columnCindex` USING BTREE (`columnC`),

将导出文件中的所有索引类型(USING BTREE 等)挪到索引列(columnB等)的前面,问题解决

你可能感兴趣的:(Error Code: 1064 – You have an error in your SQ...)