How can I import data into mysql database via mysql workbench?
Master System Design with Codemia
Enhance your system design skills with over 120 practice problems, detailed solutions, and hands-on exercises.
Introduction
MySQL Workbench can import data in more than one way, and the right method depends on what kind of file you have. A full SQL dump is usually imported through the Data Import screen, while CSV-style tabular data is often easier through the Table Data Import Wizard.
Importing a .sql Dump File
If your input is a SQL dump created by mysqldump or a similar tool, use the main Data Import workflow.
Typical steps in MySQL Workbench are:
- connect to the target MySQL server
- open
Serverand thenData Import - choose
Import from Self-Contained File - browse to the
.sqlfile - select the target schema or create one first
- start the import
This method is best when the file already contains SQL statements such as CREATE TABLE, INSERT, and possibly index or constraint definitions.
If you prefer the SQL editor, you can also open the file and execute it directly:
That is conceptually simple, but the Data Import screen is usually easier for larger dump files and clearer for less command-line-oriented workflows.
Importing CSV Data into a Table
If the source is a CSV file rather than a SQL dump, Workbench usually expects you to import it into an existing or new table. The easiest route is the Table Data Import Wizard.
Typical workflow:
- create the target schema if needed
- create or select the destination table
- right-click the table in the schema browser
- choose
Table Data Import Wizard - select the CSV file
- map columns and review types
- complete the import
This is useful when the file is plain rows and columns rather than executable SQL.
For example, if your CSV looks like this:
Workbench can map each CSV column into the destination table columns during the wizard flow.
Prepare the Table First When Needed
CSV import works more smoothly when the destination table structure is already clear. For example:
Then use the wizard to load the rows. This avoids guesswork around types and prevents the import from creating an unexpected schema.
When LOAD DATA INFILE Is Better
For larger datasets, Workbench may still be only the interface, while the actual best import mechanism is MySQL's LOAD DATA command.
Workbench can run this SQL in the query editor. This approach is often faster and more explicit than clicking through the wizard, especially when you are repeating the same import in multiple environments.
Validate After Import
Always inspect the imported data instead of assuming success because the dialog finished without errors.
Simple checks include:
If the row count is unexpectedly low, or if columns appear shifted, the delimiter, quoting, encoding, or table definition may not match the source file.
Common Pitfalls
- Using the SQL dump import workflow for CSV files or the CSV wizard for full SQL dumps.
- Importing into a table with the wrong column order or incompatible types.
- Forgetting to create or select the intended target schema before importing.
- Assuming a successful import dialog means the data was mapped correctly.
- Ignoring file encoding, delimiters, or header-row settings when working with CSV data.
Summary
- Use the Data Import screen for
.sqldump files. - Use the Table Data Import Wizard for CSV-style tabular data.
- Create the destination table explicitly when you want predictable column types.
- For large repeated imports,
LOAD DATA INFILEis often the clearer and faster option. - Always validate the imported row count and sample records after the import completes.

