应该指定pet.txt的绝对路径
这是我的操作,正确!
mysql> LOAD DATA INFILE "d:/abc/pet.txt" INTO TABLE aa;
Query OK, 9 rows affected (0.02 sec)
Records: 9  Deleted: 0  Skipped: 0  Warnings: 54

解决方案 »

  1.   

    我用过这个,好像没有什么问题的是不是应该把txt文件放在根目录下?
      

  2.   

    呵呵,不是,
    主要是你用了LOCAL 关键字
      

  3.   

    找到以下資料:
    If the LOCAL keyword is not present, MySQL looks for the datafile on the server host.
    我將pet.txt 放到C:\mysql\data\menagerie
    shell>LOAD DATA INFILE 'pet.txt'INTO TABLE pet ;或者
    shell>LOAD DATA INFILE 'menagerie/pet.txt'INTO TABLE pet ok,無問題.If the LOCAL keyword is specified, MySQL looks for the file on the client host, and interprets the pathname the same way your command interpreter does將pet.txt 放到d:\pet 
    mysql> LOAD DATA LOCAL 'd:/pet/pet.txt' INTO table pet ;ERROR 1148: The used command is not allowed with this MySQL versionmysql>LOAD DATA  'd:/pet/pet.txt' INTO table pet 
    Query OK.可能这个原因?
    As of MySQL 3.23.49, use of the LOCAL keyword may be disabled by default. You may be able to turn it on using the --local-infile option for mysql. If that doesn't work, your server has been configured not to allow LOAD DATA LOCAL at all.
    于时执行msyql>--local-infile 
    再试,mysql> LOAD DATA LOCAL 'd:/pet/pet.txt' INTO table pet 
    还是出现error1148:
    算了.准备结贴!!!
    不得不说,mysql文档自带教程却一笔带过,只字不提local,靠,让人不知所谓,百思不得其解.
    To load the text file `pet.txt' into the pet table, use this command: 
    mysql> LOAD DATA LOCAL INFILE "pet.txt" INTO TABLE pet;You can specify the column value separator and end of line er explicitly in the LOAD DATA statement if you wish, but the defaults are tab and linefeed. These are sufficient for the statement to read the file `pet.txt' properly.