[Err] 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 ''<h1 style="text-align: center;">php实现 字符串分割</h' at line 1

一、总结

一句话总结:我本来都是直接打开sql复制里面的内容到mysql中执行,这次是用nodepad++,所以出错。这不是错误,1064是语法错误。

二、[Err] 1064 - You have an error in your SQL syntax; check the manual that corresponds to your MySQL s

[Err] 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 at line 3

MySQL 5.6,Navicat For MySQL 10.0.10 中执行SQL语句时提示此错误,在CMD中执行SQL文件中的语句时提示以下错误:

 D:\Users\Aven>mysql -uroot -p < F:\Publish\Data\share_update.sql
Warning: Using a password on the command line interface can be insecure.
ERROR 1064 (42000) at line 4: 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 'ALTER聽TABLE聽mcu聽CHANGE聽`LOCAL_ID`聽`LOCAL_ID`聽VARCHAR(50)聽'
at line 1

解决方案:

发现解决该问题的关键,是错误提示中的空格都是“聽”,这让我想到是文件的编码问题,然后做文件编码的转换。 
推荐使用Notepad++,编码转换非常方便,如图: 

转换为UTF-8格式,问题依旧,再转为ANSI格式试试: 

哈哈,原形毕露了吧!把?都替换为空格,保存,再执行,一切OK了。

反思:

为什么会出现这种问题呢? 
这些语句是从QQ复制到Word中,又从Word中复制到Notepad++中, 
估计是从QQ或Word中复制出来的空格有问题。

三、完美解决 ERROR 1064 (42000): You have an error in your SQL syntax ... near …

在MySQL命令行使用sql语句进行建表时,MySQL 报错,这个问题之前遇到过几次,但是总是会因为疏忽又相遇,今天把这个问题写出来,加深印象吧。

sql语句:

CREATE TABLE 'lrs_audit_rule_package'(
'id' BIGINT(20) AUTO_INCREMENT PRIMARY KEY COMMENT '主键',
'package_code' varchar(6) NOT NULL COMMENT '规则包',
'package_type' varchar(2) NOT NULL COMMENT '规则包类型',
'package_desc' varchar(100) COMMENT '描述',
'create_time' datetime DEFAULT NULL COMMENT '创始时间',
'modified_time' datetime DEFAULT NULL COMMENT '修改时间'
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='审核规则包';

看上去这条sql语句确实没毛病,但是运行起来就是报错
报错信息:

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 ''lrs_audit_rule_package'(
'id' BIGINT(20) AUTO_INCREMENT PRIMARY KEY COMMENT ' at line 1

其实这个问题就是语法上的错误,在MySQL中,为了区分MySQL的关键字与普通字符,MySQL引入了一个反引号。
详情见:https://dev.mysql.com/doc/refman/5.5/en/keywords.html

在上述的sql语句中,列名称使用的是单引号而不是反引号,所以会就报了这个错误出来。修改后

CREATE TABLE `lrs_audit_rule_package`(
`id` BIGINT(20) AUTO_INCREMENT PRIMARY KEY COMMENT '主键',
`package_code` varchar(6) NOT NULL COMMENT '规则包',
`package_type` varchar(2) NOT NULL COMMENT '规则包类型',
`package_desc` varchar(100) COMMENT '描述',
`create_time` datetime DEFAULT NULL COMMENT '创始时间',
`modified_time` datetime DEFAULT NULL COMMENT '修改时间'
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='审核规则包';

再次运行就不会报错了,但是有一点需要注意,后面列的注释不能用反引号,因为这只是一个普通字符串,不是MySQL的关键字。

在英文键盘输入环境下,按图示按钮输入反引号 `

 

[Err] 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 ''&lt;h1 style=&quot;text-align: center;&quot;&gt;php的更多相关文章

  1. MySql 执行语句错误 Err] 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

    关于用Power Designer 生成sql文件出现 错误  [Err] 1064 - You have an error in your SQL syntax; check the manual ...

  2. 插入mysql语句报错: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

    插入一个很简单的sql语句时候,mysql一直报错: [SQL] INSERT INTO ORDER ( id, activity_id, order_type, phone, order_amoun ...

  3. 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 'groups)VALUES('1','hh','hh@163.com','Boss')' at line 1

    mysql8.0版本 在已存在的表里插入一条数据 insert INTO api_user(id,username,email,groups)VALUES('1','hh','hh@163.com', ...

  4. 解决ROR 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 'creat table study_record( id int(11) not null

    之前一直用的好好的,突然就出现了这个错误: ERROR 1064 (42000): You have an error in your SQL syntax; check the manual tha ...

  5. ERROR: 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 'type=InnoDB' at line 7

    问题: 使用hibernate4.1.1,数据库使用mysql5.1.30,使用hibernate自动生成数据库表时,hibernate方言使用org.hibernate.dialect.MySQLI ...

  6. C# Mysql 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 ????

    有几年没用过MySql数据了,今天在使用C#访问MySql数据库时出现了一个小插曲. 错误提示: You have an error in your SQL syntax; check the man ...

  7. 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 '

    mysql中如果字段使用了关键字,在插入和更新时会提示 You have an error in your SQL syntax; check the manual that corresponds ...

  8. MySQLSyntaxErrorException: 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 ...

    下面是我update数据库时打印出来的异常: ### Error updating database. Cause: com.mysql.jdbc.exceptions.jdbc4.MySQLSynt ...

  9. 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 'like '%逸%'' at line 1

    <?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE mapper PUBLIC "-/ ...

随机推荐

  1. Spring 热点面试题:

    1.谈谈你对Springaop的理解? spring用代理类包裹切面,把他们织入到Spring管理的bean中.也就是说代理类伪装成目标类,它会截取对目标类中方法的调用,让调用者对目标类的调用都先变成 ...

  2. ORA-00922: 选项缺失或无效

    1.错误描写叙述 SQL> create table info_stu from select t.stu_id,t.stu_name,t.stu_age from info t; create ...

  3. Python 值传递和引用传递

    值传递和引用传递 參考地址:http://www.dataguru.cn/thread-489552-1-1.html python的值传递不会改变传入參数的值,而引用传递传入的是一个地址.有点相似c ...

  4. mysql_jdbc

    package com.lovo.day18_jdbc1; import java.sql.Connection; import java.sql.DriverManager; import java ...

  5. OpenCascade Sweep Algorithm

    OpenCascade Sweep Algorithm eryar@163.com Abstract. Sweeps are the objects you obtain by sweeping a ...

  6. mongodb与SQL相应关系表

    1. select查询 mongodb使用find或者findOne来查询: find批量查询. findOne是查询一条记录. find有两个參数: 第一个查询条件, 第二个查询返回的字段. 以下是 ...

  7. ubuntu-删除内核

    今天进入公司第一天,公司需要给电脑安装ubuntu,这个是由it部门帮忙安装的.但是,我不小心升级了内核版本,接下来就悲剧了,因为内核版本升级以后,直接导致了环境错误,很多公司内部使用的工具都不能用了 ...

  8. js数组sort方法详解

    在处理数组的时候,我们有时候需要对数组进行排序,排序的方法有很多种,但是最好最快的就是利用sort方法进行快速的排序. 我们来看一个例子: var arr1 = [6, 3, 4, 1, 2, 5, ...

  9. Java_Learn

    20180417 集合类 Collection 如果是实现了list接口的集合类,具备的特点是有序,可重复: 如果是实现了set接口的集合类,具备的特点是无序,不可重复: Collection中的方法 ...

  10. 解决create-react-app 后 npm start 中出现 的webpack版本问题和webpack-dev-server的版本问题

    利用VSCode搭建react的脚手架运行环境的时候.create-react-app之后npm start出现如下图的问题: There might be a problem with the pr ...