Import multiple csv files

from the Artful MySQL Tips List

Substitute your path, database and table for yourpath, yourDB and yourtable in ...
#!/usr/bin/env bash
cd yourpath
for f in *.csv
  mysql -e "USE yourDB LOAD DATA LOCAL INFILE '"$f"'INTO TABLE yourtable"

Last updated 1 Aug 2019

Return to the Artful MySQL Tips page