I have recently switched web hosting providers and the new provider does not allow 'load data infile' commands in MySQL. However, I have many CSV files that update tables in a database weekly using that command. What is the best way to import into MySQL without the typical load data option? I tried mysqlimport, but that seems to fail since the data isn't in SQL format, its just standard CSV data. Thanks for your help.
Asked
Active
Viewed 1,109 times
0
-
Script to read the CSV, then build the `INSERT` statements yourself? – jimbobmcgee Oct 18 '13 at 18:53
-
@user2895995 - Have you tried `load data LOCAL infile`? There's also a `mysqlimport` command in Linux that performs the same functionality, otherwise you'll have to do what jimbobmcgee recommended and create inserts. – Emo Mosley Oct 18 '13 at 18:55
-
Yes, I have tried the local option, but the 'load' command in general is blocked. How can you specify which table to import into using mysqlimport? – user2895995 Oct 18 '13 at 19:03
-
Just found out that mysqlimport is also blocked by the web host. I guess I may be making the inserts from the file. – user2895995 Oct 18 '13 at 19:19
-
MySQL CSV Storage Engine might help you out here – Tom Mac Oct 18 '13 at 21:12
1 Answers
0
Use the following process:
- Convert the CSV to the MySQL CSV dump format
- Upload the file to the MySQL server or to the shared hosting file system
Use one of the following commands to import it:
mysqladmin:
mysqladmin create db1 mysql db1 < dump.csv
mysql:
mysql> CREATE DATABASE IF NOT EXISTS db1; mysql> USE db1; mysql> source dump.csv
References

Paul Sweatte
- 24,148
- 7
- 127
- 265