Is there a way to import multiple csv files at the same time into a MySQL database? Some sort of batch import?
I'm on Mac OSX running a MAMP server.
I have 185 csv files that I need to import into a MySQL table. I can import them individually using phpMyAdmin's import tab, but it would take a long time. Does anyone know if there is a better way?
解决方案
Use a shell script like this:
#!/usr/bin/env bash
cd yourdirectory
for f in *.csv
do
mysql -e "USE yourDatabase LOAD DATA LOCAL INFILE '"$f"'INTO TABLE yourtable"
done