使用 BTREE 的 MySQL 错误
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/3767753/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
MySQL error USING BTREE
提问by r1400304
I have a mysql database I have downloaded from my online server and trying to import on my local mysql but its not working showing this syntax error. I cannot find any errors in this query
我有一个 mysql 数据库,我已经从我的在线服务器下载并尝试在我的本地 mysql 上导入,但它无法正常工作,显示此语法错误。我在此查询中找不到任何错误
This is the error:
这是错误:
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, KEY
idx_p_id
(p_id
) USING BTREE, KEY ' at line 27
1064 - 你的 SQL 语法有错误;检查与您的 MySQL 服务器版本相对应的手册,了解在第 27 行的“USING BTREE, KEY
idx_p_id
(p_id
) USING BTREE, KEY ”附近使用的正确语法
and this is my query:
这是我的查询:
PRIMARY KEY (`a_id`),
UNIQUE KEY `idx_a_id` (`a_id`) USING BTREE,
KEY `idx_p_id` (`p_id`) USING BTREE,
KEY `idx_m_id` (`m_id`)
) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=latin1;
回答by The Surrican
Your mysql server version is older and not compatible with the one where the dump was created.
Try to upgrade your mysql server or to export the dump using the --compatible
option of mysqldump.
您的 mysql 服务器版本较旧并且与创建转储的版本不兼容。尝试升级您的 mysql 服务器或使用--compatible
mysqldump 选项导出转储。
You probably need this:
你可能需要这个:
mysqldump --compatible=mysql40 ...
You also have the option to import the dump to a newer server which you can create locally and re-export there using the comopatible option.
您还可以选择将转储导入到较新的服务器,您可以在本地创建该服务器并使用兼容选项在那里重新导出。
I have also seen people search and replacing stuff in their mysql dump files but this is an ugly approach, but might work for you if you have just this incompatibility.
我还看到人们在他们的 mysql 转储文件中搜索和替换内容,但这是一种丑陋的方法,但如果您有这种不兼容性,可能对您有用。
also format your text a little bit and accept some answers if you want people to help you.
如果您希望人们帮助您,还可以稍微格式化您的文本并接受一些答案。
回答by twonkeys
In the version I am using (5.0.51a), USING BTREE
issupported. However, the syntax differs slightly: at least within a CREATE TABLE
statement, the USING BTREE
part must be between the index name and its colums; e.g.
在我使用(5.0.51a)的版本,USING BTREE
被支持。然而,语法略有不同:至少在一个CREATE TABLE
语句中,该USING BTREE
部分必须在索引名称和它的列之间;例如
INDEX ind USING BTREE (col1, col2)
索引索引使用 BTREE (col1, col2)
Although the 5.0 manual says the index_type
may come before orafter the column definitions, the latter is not accepted.
尽管 5.0 手册说index_type
可能出现在列定义之前或之后,但后者不被接受。
I can't say anything about the behaviour in version 5.1.
我对 5.1 版中的行为无话可说。
回答by jazkat
This is what I found that helped: Mysql: USING BTREE – Error when dumping from 5.1 and importing to 5.0
回答by Michael Eakins
It appears that your problem may be a result of a MYSQL bug noted in the following link.
您的问题似乎是由以下链接中提到的 MYSQL 错误引起的。
回答by Abadis
In Version 5.1X you can use BTREE but in older versions it is not possible. to use BTREE in older versions like 5.0x you should just set the index and it doesnt have any option.watch here
在 5.1X 版中,您可以使用 BTREE,但在旧版本中则无法使用。要在 5.0x 等旧版本中使用 BTREE,您应该只设置索引并且它没有任何选项。在这里观看
You can see what is in version 5.0x below :
您可以在下面看到 5.0x 版中的内容:
MyISAM => BTREE
InnoDB => BTREE
MEMORY/HEAP => HASH, BTREE
NDB => BTREE, HASH
回答by maxmas
The reason for the error is different version of the database. Difference between mysql 5.0 and mysql 5.1
错误的原因是数据库版本不同。mysql 5.0 和 mysql 5.1 的区别
mysql 5.0 -> KEY idx_p_id
(p_id
) USING BTREE,
mysql 5.0 -> KEY idx_p_id
( p_id
) 使用 BTREE,
mysql 5.1 -> KEY idx_p_id
USING BTREE (p_id
),
mysql 5.1 ->idx_p_id
使用 BTREE ( p_id
) 的密钥,