错误代码1064,SQL状态42000:SQL语法中有错误;

时间:2022-09-07 15:48:21

I'm using latest version of MySQL ==> mysql-5.6.10-winx64.zip

我使用最新版本的MySQL ==> MySQL -5.6.10-winx64.zip

Created the database and every thing is ok 'I think' when I try to execute this simple command;

创建了数据库,当我尝试执行这个简单的命令时,一切都没问题;

"select * from family"

I got this error :

我得到了这个错误:

Error code 1064, SQL state 42000: 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 'OPTION SQL_SELECT_LIMIT=DEFAULT' at line 1

错误代码1064,SQL状态42000:在SQL语法中有错误;检查与MySQL服务器版本对应的手册,以获得在第1行使用“选项SQL_SELECT_LIMIT=DEFAULT”的正确语法

I've spent much time searching for a solution but no solution was found :(

我花了很多时间寻找解决方案,但是没有找到

6 个解决方案

#1


29  

That looks like an error coming from a JDBC driver. When the JDBC driver initializes the connection, it sends several commands to the MySQL server, one of which is:

这看起来像是来自JDBC驱动程序的错误。当JDBC驱动程序初始化连接时,它向MySQL服务器发送几个命令,其中一个是:

SET OPTION SQL_SELECT_LIMIT=DEFAULT

The problem is that the SET OPTION syntax has been deprecated for some time and is now no longer valid in MySQL 5.6. Here's a relevant bug conversation from MySQL's bug database:

问题是,SET选项语法已经被弃用了一段时间,现在在MySQL 5.6中不再有效。下面是来自MySQL的bug数据库的相关bug对话:

Bug #66659: mysql 5.6.6m9 fails on OPTION SQL_SELECT_LIMIT=DEFAULT

错误#66659:mysql 5.6.6m9在选项SQL_SELECT_LIMIT=DEFAULT上失败

Try upgrading your JDBC MySQL driver. The bug conversation lists some other options in case upgrading the driver is not an option.

尝试升级您的JDBC驱动程序。bug对话列出了一些其他选项,以防升级驱动程序不是选项。

#2


11  

I followed the instructions above and this worked for me!

我遵循上面的说明,这对我很有效!

  1. Download latest jar file from here: http://dev.mysql.com/downloads/mirror.php?id=412737 Unzip it Copy jar file "mysql-connector-java-5.1.25-bin.jar" to this folder: C:\Program Files\NetBeans 7.3\ide\modules\ext

    从这里下载最新的jar文件:http://dev.sqmyl.com/downloads/mirror.php?id=412737解压它拷贝jar文件“mysql-connector-java- 5.25 bin”。jar”这个文件夹:C:\Program Files\NetBeans 7.3模块\ ide \ \ ext

  2. In Netbeans IDE: Disconnect from database. Click Services. Expand Drivers. Right-click on MySQL and press Customize. Add latest driver Remove previous driver.

    在Netbeans IDE中:断开与数据库的连接。点击服务。扩大的司机。右键单击MySQL并按自定义。添加最新的驱动程序删除先前的驱动程序。

  3. Re-connect to dabatase within IDE.

    重新连接到IDE中的dabatase。

#3


5  

I had the same problem few weeks back. Followed the following steps and it very much resolved the issue.

几周前我也遇到过同样的问题。按照下面的步骤,它在很大程度上解决了这个问题。

  1. Copied the latest version (mysql-connector-java-5.1.23-bin) of the jar file to ..\NetBeans 7.3\ide\modules\ext. My earlier version of the driver was mysql-connector-java-5.1.18-bin.

    将jar文件的最新版本(mysql-connector-java-5.1.23-bin)复制到…模块\ NetBeans ide 7.3 \ \ \ ext。我之前的驱动版本是mysql-connector-java-5.1.18 bin。

  2. Change the driver version within NetBeans IDE. In the IDE's Services window, expand Drivers -> right-click on MySQL (Connector/J driver) and select Customize. Remove the earlier driver and point it to the latest one (C:\Program Files (x86)\NetBeans 7.3\ide\modules\ext\mysql-connector-java-5.1.23-bin.jar). Click ok and restart IDE.

    在NetBeans IDE中更改驱动程序版本。在IDE的服务窗口中,展开驱动程序——>右键单击MySQL(连接器/J驱动程序)并选择Customize。删除之前的驱动程序并指向最新的驱动程序(C:\Program Files (x86)\NetBeans 7.3\ide modules\ext\ ext\mysql-connector- connector-java- 5.23 -bin.jar)。单击ok并重新启动IDE。

This should resolve the problem.

这应该能解决问题。

#4


0  

If the driver suggestion does not work, check your sql for unprintable characters. I just spent an hour troubleshooting this issue only to discover a hidden u+200b character at the end of my sql statement.

如果驱动程序建议不起作用,请检查sql中是否有不能打印的字符。我刚刚花了一个小时对这个问题进行故障排除,结果在sql语句的末尾发现了一个隐藏的u+200b字符。

#5


0  

I got the same Error when i was dumping mysql table structure file in to DB. Mistake was putting the Syntax for dropping all table before but not checking their existence in the Database. Issue was at " DROP TABLE usermgmt". I removed that code of lines of dropping tables and it proceeded with out any error this time.

当我将mysql表结构文件转储到DB时,我得到了同样的错误。错误在于将删除所有表的语法放在前面,而不检查它们在数据库中的存在性。问题是“DROP TABLE usermgmt”。我删除了几行删除表的代码,这次它继续输出任何错误。

#6


0  

I prefixed the name of the table with the database name such as

我在表的名称前面加上了数据库名,例如

select * from database_name.table_name;

and it worked perfectly, so most likely there's a name conflict.

而且效果很好,所以很可能有名字冲突。

#1


29  

That looks like an error coming from a JDBC driver. When the JDBC driver initializes the connection, it sends several commands to the MySQL server, one of which is:

这看起来像是来自JDBC驱动程序的错误。当JDBC驱动程序初始化连接时,它向MySQL服务器发送几个命令,其中一个是:

SET OPTION SQL_SELECT_LIMIT=DEFAULT

The problem is that the SET OPTION syntax has been deprecated for some time and is now no longer valid in MySQL 5.6. Here's a relevant bug conversation from MySQL's bug database:

问题是,SET选项语法已经被弃用了一段时间,现在在MySQL 5.6中不再有效。下面是来自MySQL的bug数据库的相关bug对话:

Bug #66659: mysql 5.6.6m9 fails on OPTION SQL_SELECT_LIMIT=DEFAULT

错误#66659:mysql 5.6.6m9在选项SQL_SELECT_LIMIT=DEFAULT上失败

Try upgrading your JDBC MySQL driver. The bug conversation lists some other options in case upgrading the driver is not an option.

尝试升级您的JDBC驱动程序。bug对话列出了一些其他选项,以防升级驱动程序不是选项。

#2


11  

I followed the instructions above and this worked for me!

我遵循上面的说明,这对我很有效!

  1. Download latest jar file from here: http://dev.mysql.com/downloads/mirror.php?id=412737 Unzip it Copy jar file "mysql-connector-java-5.1.25-bin.jar" to this folder: C:\Program Files\NetBeans 7.3\ide\modules\ext

    从这里下载最新的jar文件:http://dev.sqmyl.com/downloads/mirror.php?id=412737解压它拷贝jar文件“mysql-connector-java- 5.25 bin”。jar”这个文件夹:C:\Program Files\NetBeans 7.3模块\ ide \ \ ext

  2. In Netbeans IDE: Disconnect from database. Click Services. Expand Drivers. Right-click on MySQL and press Customize. Add latest driver Remove previous driver.

    在Netbeans IDE中:断开与数据库的连接。点击服务。扩大的司机。右键单击MySQL并按自定义。添加最新的驱动程序删除先前的驱动程序。

  3. Re-connect to dabatase within IDE.

    重新连接到IDE中的dabatase。

#3


5  

I had the same problem few weeks back. Followed the following steps and it very much resolved the issue.

几周前我也遇到过同样的问题。按照下面的步骤,它在很大程度上解决了这个问题。

  1. Copied the latest version (mysql-connector-java-5.1.23-bin) of the jar file to ..\NetBeans 7.3\ide\modules\ext. My earlier version of the driver was mysql-connector-java-5.1.18-bin.

    将jar文件的最新版本(mysql-connector-java-5.1.23-bin)复制到…模块\ NetBeans ide 7.3 \ \ \ ext。我之前的驱动版本是mysql-connector-java-5.1.18 bin。

  2. Change the driver version within NetBeans IDE. In the IDE's Services window, expand Drivers -> right-click on MySQL (Connector/J driver) and select Customize. Remove the earlier driver and point it to the latest one (C:\Program Files (x86)\NetBeans 7.3\ide\modules\ext\mysql-connector-java-5.1.23-bin.jar). Click ok and restart IDE.

    在NetBeans IDE中更改驱动程序版本。在IDE的服务窗口中,展开驱动程序——>右键单击MySQL(连接器/J驱动程序)并选择Customize。删除之前的驱动程序并指向最新的驱动程序(C:\Program Files (x86)\NetBeans 7.3\ide modules\ext\ ext\mysql-connector- connector-java- 5.23 -bin.jar)。单击ok并重新启动IDE。

This should resolve the problem.

这应该能解决问题。

#4


0  

If the driver suggestion does not work, check your sql for unprintable characters. I just spent an hour troubleshooting this issue only to discover a hidden u+200b character at the end of my sql statement.

如果驱动程序建议不起作用,请检查sql中是否有不能打印的字符。我刚刚花了一个小时对这个问题进行故障排除,结果在sql语句的末尾发现了一个隐藏的u+200b字符。

#5


0  

I got the same Error when i was dumping mysql table structure file in to DB. Mistake was putting the Syntax for dropping all table before but not checking their existence in the Database. Issue was at " DROP TABLE usermgmt". I removed that code of lines of dropping tables and it proceeded with out any error this time.

当我将mysql表结构文件转储到DB时,我得到了同样的错误。错误在于将删除所有表的语法放在前面,而不检查它们在数据库中的存在性。问题是“DROP TABLE usermgmt”。我删除了几行删除表的代码,这次它继续输出任何错误。

#6


0  

I prefixed the name of the table with the database name such as

我在表的名称前面加上了数据库名,例如

select * from database_name.table_name;

and it worked perfectly, so most likely there's a name conflict.

而且效果很好,所以很可能有名字冲突。