Error Code: 1064 – You have an error in your SQL syntax解決幾個方法mysql
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 BTREEsql
分析緣由可能使用了高版本的SQL語句在低版本中導入,數據庫
最後在網上查找整理出如下幾個解決方法:
1,升級MYSQL數據庫到相應的對應版本(這個可能很麻煩)ssh
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等)的前面,問題解決server