Agile FAQs
  About   Slides   Home  

 
Managed Chaos
Naresh Jain's Random Thoughts on Software Development and Adventure Sports
     
`
 
RSS Feed

Recent Thoughts
Tags
Recent Comments

MySQL Load Data Infile: ERROR 1045 (28000): Access denied for user…

Recently I was trying to load a CSV file into a MySQL database on a Linux box using the following command:

LOAD DATA INFILE '/path/to/my_data.csv' INTO TABLE `my_data`
        FIELDS TERMINATED BY ',' ENCLOSED BY '"'
        LINES TERMINATED BY '\r\n';

I kept getting the following error:

ERROR 1045 (28000): Access denied for user …

After Googling around I got some suggestions:

  • chown mysql.mysql my_data.csv; chmod 666 my_data.csv
  • move the data file to /tmp folder, where all processes have read access
  • Grant a FILE permissions to the user. Basically GRANT *.* usage.
  • Load data LOCAL infile…

Nothing seemed to help.

Luckily I found the following command which did the job:

mysqlimport -v --local --fields-enclosed-by='"'
        --fields-escaped-by='\'
        --fields-terminated-by=','
        --lines-terminated-by='\r\n'
        -u[db_user] -p[db_password] -h [hostname] [db_name]
        '/path/to/my_data.csv'

Related posts:

  1. Continue to get MySQL table crashed error on TikiWiki
  2. MySQL Table Crash
  3. Value Objects Aren’t Data Classes
  4. Stored proc to page sorted data
  5. 7 Simple Steps to access Linux File System using Samba
  • Stephen Souness

    I don't use there commands all that often myself, but I suspect the ` character around your table name might be getting interpreted differently to the way you expect.

    If that isn't the source of the problem, then you can always take a look at the source code of mysqlimport. It's just using a LOAD DATA command after all.

    The beauty of open source.

  • Stephen Souness

    I don't use there commands all that often myself, but I suspect the ` character around your table name might be getting interpreted differently to the way you expect.

    If that isn't the source of the problem, then you can always take a look at the source code of mysqlimport. It's just using a LOAD DATA command after all.

    The beauty of open source.

  • http://www.air-jordan-19.com air jordan 19

    “Here air jordan 21 products xx, has fashion model, superior quality and service, cheap price and updates quickly.I support strongly always! I want to buy XX, I hesitate to select which style more better.Hope your unique recommends.


    Licensed under
Creative Commons License