简体   繁体   中英

Import CSV file into MySQL without using load data infile

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.

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM