Mastering MySQL for Data AnalystsLesson 6 of 42
Lesson 6 of 42

Bulk Data Ingestion: MySQL Workbench Import Wizard & LOAD DATA INFILE

Overview & Learning Objectives

Data analysts rarely input millions of rows manually; data arrives via external CSV exports from third-party tools, ERP systems, or POS terminals. MySQL offers two primary ingestion avenues: the visual MySQL Workbench Table Data Import Wizard for ad-hoc files, and the blazing-fast `LOAD DATA INFILE` command for production multi-million row bulk loads.

  • Import external CSV datasets using the MySQL Workbench Table Data Import Wizard.
  • Master high-speed bulk ingestion using `LOAD DATA INFILE` with custom delimiters and line terminators.
  • Configure `local_infile = 1` and handle common file path permissions.

Industry Standard

Standard: ETL pipelines at Walmart and Target utilize `LOAD DATA LOCAL INFILE` to ingest multi-gigabyte point-of-sale flat files in seconds rather than hours of row-by-row INSERTs.

Real-World Example: ScoopCraft Nightly Delivery Batch Ingestion

ScoopCraft ingests 50,000 daily order records from delivery partner CSV drops into its MySQL analytics warehouse.

Ingestion MethodDataset SizeExecution TimeBest Used For
Workbench GUI Wizard5,000 rows35 secondsAd-hoc exploratory CSV review
LOAD DATA INFILE5,000,000 rows4.2 secondsProduction automated nightly batch jobs
Workbench Export Wizard10,000 rows12 secondsSharing CSV reports with store managers

Syntax & Core SQL Implementation

-- High-performance bulk CSV loading in MySQL
LOAD DATA LOCAL INFILE '/path/to/zepto_orders.csv'
INTO TABLE orders
FIELDS TERMINATED BY ',' 
ENCLOSED BY '"'
LINES TERMINATED BY '\n'
IGNORE 1 ROWS
(order_id, customer_id, outlet_name, total_amount, order_status, order_date);

Parameters & Arguments Breakdown

  • LOAD DATA LOCAL INFILE: Reads data directly from client filesystem into MySQL table at bare-metal speed.
  • FIELDS TERMINATED BY: Specifies the column delimiter (comma "," for standard CSV, "\t" for TSV).
  • ENCLOSED BY: Handles text strings containing embedded commas wrapped in quotation marks.
  • IGNORE 1 ROWS: Skips the CSV column header row.

Sample Walkthrough (Q&A)

Question: Why does LOAD DATA INFILE run 50x-100x faster than traditional multi-row INSERT statements?

SQL Pattern: LOAD DATA INFILE vs INSERT

Result: Bypasses SQL parser and query optimization overhead; streams raw text directly into InnoDB buffer pool pages

Explanation: Loads data directly into memory blocks with minimal per-row transaction logging overhead.

Common Mistakes & Limitations

  • Encountering `ERROR 2068 (HY000): LOAD DATA LOCAL INFILE file request rejected due to restrictions`; requires setting `local_infile = 1` on both client and server.
  • Forgetting `IGNORE 1 ROWS`, causing the text header names to be inserted as data and triggering data type mismatch errors on numeric columns.

Keyboard Shortcuts (MySQL Workbench)

ActionWindowsMac
Right-Click Table in WorkbenchTable Data Import WizardTable Data Import Wizard

Pro Tips & Modern Best Practices

  • Enable local infile in MySQL client using `mysql --local-infile=1 -u root -p` before executing bulk file imports.
  • When importing dates in non-standard formats (e.g. DD/MM/YYYY), load into a temporary variable `@date_var` and apply `STR_TO_DATE(@date_var, "%d/%m/%Y")` inline.