MySQL bulk insert from CSV data files

后端 未结 1 973
感动是毒
感动是毒 2020-12-10 20:16

I have some CSV data files that I want to import into mySQL. I would like to do the insert in a shell script, so that it can be automated. However, I am a bit weary of havin

相关标签:
1条回答
  • 2020-12-10 20:28

    You should read about mysqlimport, which is a command-line tool provided with MySQL. This tool is the fastest way to bulk-load CSV data.

    The tool has two options, --replace and --ignore to handle duplicate key conflicts.

    Regarding security and avoiding putting the password in plain text in the script, you can also use the MYSQL_PWD environment variable or the .my.cnf file (make sure that file is mode 400 or 600). See End-User Guidelines for Password Security.

    0 讨论(0)
提交回复
热议问题