导入数据语句如下:
load data infile 'd:/userDesc.txt' into table test.user(uname,num,deptNum) terminated by ',' enclosed by '\'' lines terminated by '\r\n';
报错如下:
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 'termi
nated by ',' enclosed by '\'' lines terminated by '\r\n'' at line 1load data infile 'd:/userDesc.txt' into table test.user(uname,num,deptNum) terminated by ',' enclosed by '"' lines terminated by '\r\n';
报错同上,大虾赐教

解决方案 »

  1.   

    load data infile 'd:/userDesc.txt' into table test.user FIELDS terminated by ',' enclosed by '\'' lines terminated by '\r\n' (uname,num,deptNum);
      

  2.   

    脸红一个先~居然没看到,还查了半天mysql手册。
    改回来了,谢谢大哥啊。
    不过在执行的时候又报这种错误,挺奇怪的,能不能帮忙看看啊:
    ERROR 1366 (HY000): Incorrect string value: '\xC9\xF2\xD7\xD4\xEF\xA3' for colum
    n 'uname' at row 1mysql 字符编码是utf8,user表结构为:
    +---------+--------------+------+-----+---------+----------------+
    | Field   | Type         | Null | Key | Default | Extra          |
    +---------+--------------+------+-----+---------+----------------+
    | id      | int(11)      | NO   | PRI | NULL    | auto_increment |
    | uname   | varchar(255) | YES  |     | NULL    |                |
    | num     | varchar(64)  | YES  |     | NULL    |                |
    | deptNum | varchar(255) | YES  |     | NULL    |                |
    +---------+--------------+------+-----+---------+----------------+
      

  3.   

    呵呵,搞定了,原来是我的数据文件字符编码不对,是ASCII编码的,转换了就好了,谢谢你啦
      

  4.   

    汗,又有问题,数据导入后所有的中文居然全是乱码,
    mysql字符集设置如下:
        -> ;
    +--------------------------+-------------------------------------------+
    | Variable_name            | Value                                     |
    +--------------------------+-------------------------------------------+
    | character_set_client     | utf8                                      |
    | character_set_connection | utf8                                      |
    | character_set_database   | utf8                                      |
    | character_set_filesystem | binary                                    |
    | character_set_results    | utf8                                      |
    | character_set_server     | utf8                                      |
    | character_set_system     | utf8                                      |
    | character_sets_dir       | D:\MySQL\MySQL Server 5.1\share\charsets\ |
    +--------------------------+-------------------------------------------+
    userDesc.txt字符编码通过ultraedit改为:utf-8
    show create table显示表的字符编码为utf8
    执行上面的导入语句后发现表中数据全是乱码,不知何故,网上说要改的地方都试过,没作用呢