使用LOAD INFILE将csv文件加载到MYSQL表中

时间:2015-02-06 20:04:58

标签: mysql database file load load-data-infile

我正在尝试将一个小文件加载到在MYSQL上创建的虚拟表中,但是当我尝试运行命令时,我得到以下错误。请帮我解决这个问题。谢谢。

mysql> LOAD DATA INFILE '/Users/ravitejavutukuri/Desktop/Acme Reports/abc.txt' INTO TABLE dummy FIELDS TERMINATED BY ',' LINES TERMINATED BY '\n';
ERROR 1045 (28000): Access denied for user ''@'localhost' (using password: NO)

mysql> LOAD DATA LOCAL INFILE '/Users/ravitejavutukuri/Desktop/Acme Reports/abc.txt' INTO TABLE dummy FIELDS TERMINATED BY ',' LINES TERMINATED BY '\n';
ERROR 1148 (42000): The used command is not allowed with this MySQL version

mysql> LOAD DATA INFILE '/Users/ravitejavutukuri/Desktop/Acme Reports/abc.txt' INTO TABLE dummy FIELDS TERMINATED BY ',' LINES TERMINATED BY '\n';
ERROR 1045 (28000): Access denied for user ''@'localhost' (using password: NO)

mysql> local-infile=1
    -> ;
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 'local-infile=1' at line 1

1 个答案:

答案 0 :(得分:0)

我看到了一些潜在的问题。

  1. 您需要创建表格user
  2. 您需要在MySQL中设置选项local-infile=1here

  3. 您可能需要允许该用户的权限。如果您想快速执行此操作,可以使用:GRANT ALL PRIVILEGES ON * . * TO 'newuser'@'localhost';