错误1064(42000):您的SQL语法有错误;检查与您的MySQL服务器版本对应的手册,以了解要使用的正确语法

错误1064(42000):您的SQL语法有错误;检查与您的MySQL服务器版本对应的手册,以了解要使用的正确语法,mysql,Mysql,在尝试向表中插入行时,出现以下错误: ERROR 1064 (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 ''filename') VALUES ('san', 'ss', 1, 1, 1, 1, 2, 1, 1, 'sment', 'notes','sa

在尝试向表中插入行时,出现以下错误:

ERROR 1064 (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 ''filename') 
VALUES ('san', 'ss', 1, 1, 1, 1, 2, 1, 1, 'sment', 'notes','sant' at line 1
请帮帮我

mysql> desc risks;
+-----------------+--------------+------+-----+---------------------+----------------+
| Field           | Type         | Null | Key | Default             | Extra          |
+-----------------+--------------+------+-----+---------------------+----------------+
| id              | int(11)      | NO   | PRI | NULL                | auto_increment |
| status          | varchar(20)  | NO   |     | NULL                |                |
| subject         | varchar(100) | NO   |     | NULL                |                |
| reference_id    | varchar(20)  | NO   |     |                     |                |
| location        | int(11)      | NO   |     | NULL                |                |
| category        | int(11)      | NO   |     | NULL                |                |
| team            | int(11)      | NO   |     | NULL                |                |
| technology      | int(11)      | NO   |     | NULL                |                |
| owner           | int(11)      | NO   |     | NULL                |                |
| manager         | int(11)      | NO   |     | NULL                |                |
| assessment      | longtext     | NO   |     | NULL                |                |
| notes           | longtext     | NO   |     | NULL                |                |
| submission_date | timestamp    | NO   |     | CURRENT_TIMESTAMP   |                |
| last_update     | timestamp    | NO   |     | 0000-00-00 00:00:00 |                |
| review_date     | timestamp    | NO   |     | 0000-00-00 00:00:00 |                |
| mitigation_id   | int(11)      | NO   |     | NULL                |                |
| mgmt_review     | int(11)      | NO   |     | NULL                |                |
| project_id      | int(11)      | NO   |     | 0                   |                |
| close_id        | int(11)      | NO   |     | NULL                |                |
| submitted_by    | int(11)      | NO   |     | 1                   |                |
| filename        | varchar(30)  | NO   |     | NULL                |                |
+-----------------+--------------+------+-----+---------------------+----------------+
21 rows in set (0.00 sec)

**mysql> INSERT INTO risks (`status`, `subject`, `reference_id`, `location`, `category`,
`team`, `technology`, `owner`, `manager`, `assessment`, `notes`,'filename')     VALUES 
('san', 'ss', 1, 1, 1, 1, 2, 1, 1, 'sment', 'notes','santu');**

ERROR 1064 (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 ''filename') 
VALUES ('san', 'ss', 1, 1, 1, 1, 2, 1, 1, 'sment', 'notes','sant' at line 1

不要引用列文件名

mysql> INSERT INTO risks (status, subject, reference_id, location, category, team,    technology, owner, manager, assessment, notes,filename) 
VALUES ('san', 'ss', 1, 1, 1, 1, 2, 1, 1, 'sment', 'notes','santu');

MySQL中有两种不同类型的引号。您需要对列名使用`s,对字符串使用`s。因为您在filename列中使用了“查询解析器”,所以它感到困惑。删除所有列名周围的引号,或将“filename”更改为“filename”。然后它应该可以工作。

C:\xampp>mysql-u root-p mydatabaseC:\xampp>mysql -u root -p mydatabase < C:\DB_Backups\stage-new.sql
Enter password:
ERROR 1064 (42000) at line 1: You have an error in your SQL syntax; check the ma
nual that corresponds to your MySQL server version for the right syntax to use n
ear 'stage-new.sql

----lot of space----

' at line 1
输入密码: 第1行出现错误1064(42000):SQL语法中有错误;检查ma 与您的MySQL服务器版本相对应的nual,以便使用正确的语法n ear'stage-new.sql ----很大的空间---- “在1号线 原因是当我转储数据库时,我使用了以下命令:

mysqldump -h <host> -u <username> -p <database> > dumpfile.sql
dumpfile.sql
mysqldump-h-u-p>dumpfile.sql
dumpfile.sql
由于错误,dumpfile.sql在语法中添加了两次


解决方案:我删除了添加到导出的转储文件第一行的dumpfile.sql文本。

在终端中执行转储查询,它就会工作

mysql -u root -p  <Database_Name> > <path of the input file>
mysql-u root-p>

此错误是由于2数据库中存在相同的表,例如您有project1的数据库,其中有表emp,而您又有另一个数据库,例如project2,其中有表emp,然后当您尝试在数据库中插入某些内容而不使用数据库名称时,您将收到一个错误,如

当您使用mysql查询时,解决方案是在表名的同时提到数据库名


不要使用保留关键字(如key)作为列名

此解决方案适用于windows:

  • 在管理员模式下打开命令提示符
  • 转到路径:C:\Program Files\MySQL\MySQL服务器5.6\bin
  • 运行以下命令: mysqldump-h 127.0.01-u root-proot db table1 table2>result.sql

  • 我遇到了同样的错误: 错误1064(42000):您的SQL语法有错误;检查与MySQL服务器版本相对应的手册,以获得第1行中使用的正确语法(接近',completed')

    这是我在终端上输入的输入: mysql>创建表TODO(说明,已完成)

    解决方案:对于每种列类型,必须指定它们将包含的内容类型。这可以是文本、整数、变量、布尔值。有许多不同类型的数据

    mysql>创建表TODO(描述文本,完成布尔值)

    查询正常,0行受影响(0.02秒)


    它现在已成功通过。

    当您从一个mysql关键字中获得列名时,会出现此错误。请尝试将所有列名都放在``中以运行查询

    示例:在测试中插入(`sno`、`order`、`category`、`samp`、`pamp`、`method`)值(1,1,'top',30,25,'Total')

    在本例中,列名顺序是mysql中的一个关键字,因此我必须将其放在``引号中。

    错误1064(42000):您的SQL语法有错误;查看与您的MySQL服务器版本对应的手册,以了解可在“”附近使用的正确语法 p非常简单的问题,您可以轻松解决,/p p请遵循我的步骤:更改<到(和>;到)

    只需使用:(

    在这里输入代码

    ` CREATE TABLE information (
    -> id INT(11) NOT NULL AUTO_INCREMENT,
    -> name VARCHAR(30) NOT NULL,
    -> age INT(10) NOT NULL,
    -> salary INT(100) NOT NULL,
    -> address VARCHAR(100) NOT NULL,
    -> PRIMARY KEY(id)
    -> );`
    

    将下面的代码另存为command.sql

    使用餐厅
    截断“订单”;
    截断“订单项目”;
    
    然后跑

    mysql-u root output.tab
    
    通常,在表中命名列时,我们不会记住关键字,因此最好将所有列都放在``引号中。为我修复了它。实际有用的消息如果您只是设计它,答案可能会更好。我的意思是,有一个
    输入代码
    部分可以删除。有一个
    。这是此问题的更好解决方案,因为这是更新的结果!如果你写>;它比你将面临的问题,但如果你写这);它会成功的!
    
    ` CREATE TABLE information (
    -> id INT(11) NOT NULL AUTO_INCREMENT,
    -> name VARCHAR(30) NOT NULL,
    -> age INT(10) NOT NULL,
    -> salary INT(100) NOT NULL,
    -> address VARCHAR(100) NOT NULL,
    -> PRIMARY KEY(id)
    -> );`