Import CSV into MySQL Workbench
A practical review of importing CSV and TSV files into MySQL Workbench: what the Table Data Import Wizard and LOAD DATA change, which settings protect your data, and when to stage values as plain text.
Importing a CSV file into MySQL Workbench converts flat, delimited text into rows and typed columns inside a database table. That conversion helps when you need to query, join or validate the data. It can also silently change values if the delimiter, encoding, date format or column types are wrong. This review covers what the import does, which settings decide whether your data survives intact, and when a slower or more cautious approach is the better choice.
Short verdict: is a Workbench CSV import right for your use?
For a one-off load of a modest file with clean headers, the Table Data Import Wizard is usually the simplest option. It is point-and-click, previews the parsed columns and can create the destination table for you. The decisive tradeoff is control and speed. The wizard guesses column types and offers limited transformation options. It is widely reported to be slow on large files. For large, recurring or messy imports, a LOAD DATA statement run from a Workbench SQL tab gives explicit control over parsing and conversion, but it needs extra server and client configuration.
Keep values as plain text when you are unsure what the data contains. Examples include identifiers with leading zeros, mixed date formats, or currency values with symbols. A common safe pattern is to import every column into a staging table with text columns, inspect the result, and then convert into properly typed columns with SQL. This takes an extra step but avoids type conversion you cannot undo.
What "import" means in MySQL Workbench
The word import covers several different features in Workbench, and they are easy to confuse:
- Table Data Import Wizard: the CSV and JSON importer, opened by right-clicking a table or schema in the Navigator. This is the feature most people mean.
- LOAD DATA [LOCAL] INFILE: a SQL statement you type and run in a query tab. The MySQL server or client reads the file directly.
- Server > Data Import: restores SQL dump files or dump project folders. It is not a CSV importer, so choosing it for a CSV file is a common wrong turn.
- Result grid import: some Workbench versions offer an import button in the query result grid. It is less commonly documented, so check it against your version before relying on it.
What the import actually changes
A CSV file stores only characters: field values separated by a delimiter, with optional quote characters around fields that contain delimiters or line breaks. The file has no types, no NULL marker and no declared encoding. During import, MySQL must make four decisions:
- Where each field begins and ends, based on the field separator, the quote character and the line terminator.
- How the bytes become characters, based on the character set chosen for reading the file.
- What type each value becomes, such as INT, DECIMAL, DATE or VARCHAR, according to the destination column definition.
- Whether an empty field becomes an empty string, zero, NULL or an error. This depends on the column type, the import method and the server's SQL mode.
These are stored changes, not display changes. Once the string 00742 is stored in an INT column, it is the number 742, and the leading zeros are gone from the database. A date read with the wrong format can be rejected, stored as NULL, or stored as a zero date, depending on the SQL mode. By contrast, the preview grid and result grid in Workbench are only presentation. A value that looks truncated or oddly formatted in the grid may be stored correctly, so verify with a query rather than by eye.
How to import a CSV file with the Table Data Import Wizard
The following is the general flow as documented for recent Workbench releases. Labels and screen order can differ between versions.
- Connect to the server and open the Schemas panel in the Navigator.
- Right-click the target schema to create a new table, or right-click an existing table to append to it. Choose Table Data Import Wizard.
- Select the CSV file.
- Choose the destination: an existing table, or a new table with a name you set. When creating a new table, check whether an option to drop the table if it already exists is selected. That option overwrites existing data.
- On the import settings screen, confirm the encoding and review each column. Check the source-to-destination mapping and the suggested field type. Change any type the wizard guessed wrongly, especially identifiers, postal codes, phone numbers and dates.
- If your version shows advanced options, review the field separator, line separator and quote character settings.
- Run the import, then read the summary of rows imported and any errors before closing the wizard.
Settings that decide whether the data survives
| Setting | What goes wrong if it is wrong | What to check |
| Field separator | All values end up in one column, or columns shift | Comma for CSV, tab for TSV, semicolon for many European-locale exports |
| Quote character | Commas inside quoted text split fields; quotes remain in values | Usually a double quote; confirm that embedded quotes are doubled |
| Line terminator | Stray carriage returns at the end of the last column, or one giant row | Windows files typically use CRLF; Unix and macOS files use LF |
| Encoding | Accented letters and symbols appear garbled; a byte order mark ends up in the first header | Prefer UTF-8; check whether the file was exported as UTF-8 or a legacy code page |
| Column types | Leading zeros lost, decimals rounded, long text truncated | Use VARCHAR for codes and identifiers; use DECIMAL for money |
| Date format | Dates rejected, set to NULL, or set to zero | MySQL expects YYYY-MM-DD; convert other formats during or after import |
| Empty fields | Blanks become empty strings, zeros or errors instead of NULL | Decide what a blank means and handle it explicitly |
Importing data from CSV with LOAD DATA
LOAD DATA states every parsing rule explicitly. It can also transform values as they load, using user variables and a SET clause. The example below reads a comma-separated file with a header row and converts a US-style month/day/year date. The table name, column names and file path are placeholders.
LOAD DATA LOCAL INFILE '/path/to/customers.csv'
INTO TABLE customers
CHARACTER SET utf8mb4
FIELDS TERMINATED BY ',' OPTIONALLY ENCLOSED BY '"'
LINES TERMINATED BY '\r\n'
IGNORE 1 LINES
(customer_code, full_name, @signup)
SET signup_date = STR_TO_DATE(@signup, '%m/%d/%Y');
Two configuration points commonly block this approach:
- The LOCAL keyword: the file is read from your machine. This requires the server's local_infile setting to be enabled. It also requires the client connection to allow it; in Workbench this is typically done by adding OPT_LOCAL_INFILE=1 in the connection's advanced settings.
- Without LOCAL: the file must be on the server host, and the secure_file_priv setting may restrict which directory it can be read from.
Both settings have security implications, which is why they are often off by default. On a shared or production server, ask an administrator before changing them.
TSV and other delimiters
Tab-separated files follow the same process. In LOAD DATA, use FIELDS TERMINATED BY '\t'. In the wizard, set the field separator to tab if your version exposes that option. If it does not, converting the TSV to CSV first is a workaround. Make sure the converter quotes any field that contains a comma; otherwise the conversion introduces the very splitting problem it was meant to avoid.
Will the data stay readable and usable after import?
The import is only as trustworthy as your checks after it. Useful steps include:
- Compare the row count in the table with the number of data rows in the file. Remember to subtract the header row.
- Query rows that contain accented characters, emoji or symbols, and confirm they display correctly.
- Check that the last column is clean. A trailing carriage return there usually means the line terminator was wrong.
- Look for NULL values, empty strings or zero dates where you expected real values.
- Spot-check identifiers and codes for lost leading zeros or rounding.
Problems also appear when data moves back out of the database. Exported CSV opened in a spreadsheet may be reinterpreted by the spreadsheet. Long numbers can turn into scientific notation, codes can lose leading zeros, and date-like strings can become dates. This is spreadsheet behavior, not a database change, but it can make a correct import look broken. Keep the original source file unchanged so you can re-import if a check fails.
Gaps in this review
This article is based on documented and widely described behavior of MySQL Workbench and MySQL Server. It does not include tested performance figures, row limits or timing comparisons between the wizard and LOAD DATA, because no verified measurements were available. Menu labels, wizard options and defaults vary between Workbench versions and between MySQL and compatible servers. Confirm the details against the version you use before importing important data.