You have a CSV file on your computer. Maybe it's a customer list from Excel. Maybe a dataset you downloaded. Maybe data exported from another system. Now you need to get it into MySQL and you have no idea where to start.
This is one of the most common data management tasks, and it's simpler than you think. This guide shows you five different ways to import CSV into MySQL. From the easiest zero-setup method to the most powerful command line approach. Pick the method that fits your situation and follow the steps.
What is a CSV File Anyway?
CSV stands for Comma Separated Values. It's just a text file where each line is a row of data and commas separate each column. When you export data from Excel, Google Sheets, or most databases, you get a CSV file.
A typical CSV looks like this:
id,name,email,created_at
1,Ahmed Ali,ahmed@example.com,2026-01-15
2,Sara Khan,sara@example.com,2026-01-16
3,Hassan Khan,hassan@example.com,2026-01-17
MySQL doesn't understand CSV directly. You need to import it by converting the CSV into SQL INSERT statements. That's what these methods do.
Method 1: Import CSV Online (Fastest, Zero Setup)
This is the easiest way. No installation, no command line, no technical knowledge needed. Upload your CSV file and get it in MySQL format in seconds.
Step 1. Go to the converter
Open https://dbconverter.site/csv-to-mysql
Step 2. Upload your CSV file
Click Upload File and select your CSV from your computer. The converter recognizes CSV automatically.
Step 3. Download your MySQL file
Click Convert. Your file is converted to a MySQL-ready SQL file in under one minute. Download it.
Step 4. Import into MySQL
Use the SQL file. You now have a SQL file ready to import.
This method is best if you just want it done fast without thinking about it. Your file is deleted automatically after two hours for privacy.
👉 Convert CSV to MySQL online free: https://dbconverter.site/csv-to-mysql
Method 2: Using MySQL Workbench (Best Visual Option)
MySQL Workbench is a free desktop tool that gives you a graphical interface to import CSV files without using the command line.
Step 1. Download MySQL Workbench
Go to mysql.com/products/workbench and download the free version. Install it like any other desktop app.
Step 2. Create your table
Open MySQL Workbench and connect to your database. You need to create a table first that matches your CSV structure.
If your CSV has columns: id, name, email. Create a table with those same columns:
CREATE TABLE customers (
id INT,
name VARCHAR(100),
email VARCHAR(100)
);
Step 3. Import the CSV
Right-click on your table name and select Table Data Import Wizard.
A new window opens. Click the folder icon and select your CSV file.
Step 4. Review the mapping
MySQL Workbench shows you how it is mapping CSV columns to database columns. Verify it looks correct. Then click Next and Finish.
Your CSV data is now in MySQL.
Method 3: Using phpMyAdmin (Easiest for Shared Hosting)
If your website is on shared hosting with cPanel, you already have phpMyAdmin. This is the simplest approach if you have hosting access.
Step 1. Open phpMyAdmin
Log into your hosting control panel. Find and open phpMyAdmin.
Step 2. Select or create your database
In the left sidebar, click the database you want to import into. Or create a new one if you need to.
Step 3. Create the table
Click the SQL tab and paste this command. Change column names to match your CSV:
CREATE TABLE customers (
id INT PRIMARY KEY,
name VARCHAR(100),
email VARCHAR(100)
);
Click Go.
Step 4. Import your CSV
Click the Import tab. Click Choose File and select your CSV.
Leave all settings on default and click Go at the bottom.
phpMyAdmin reads your CSV line by line and inserts the data. You see a green success message when done.
Note: phpMyAdmin has a 2MB file size limit by default. For larger files use Method 1 or Method 4.
Method 4: Using Command Line (Best for Large Files)
The command line method is fastest for large CSV files and has no size limit. It looks technical but it is just one command.
Step 1. Create your table
First, create a table in MySQL that matches your CSV structure. Use any MySQL client or phpMyAdmin.
Step 2. Open your terminal
Windows: press Windows + R, type cmd, press Enter. Mac: press Command + Space, type terminal, press Enter. Linux: press Ctrl + Alt + T.
Step 3. Run the import command
Type this command all on one line:
mysql -u your_username -p your_database -e "LOAD DATA LOCAL INFILE '/path/to/your/file.csv'
INTO TABLE customers FIELDS TERMINATED BY ',' ENCLOSED BY '\"' LINES TERMINATED BY '\n'
IGNORE 1 LINES;"
Replace these parts:
- your_username with your MySQL username
- your_database with your database name
- /path/to/your/file.csv with full path to your CSV file
- customers with your table name
Press Enter and type your password when asked.
For Windows the path looks like: C:/Users/YourName/Desktop/file.csv For Mac/Linux: /Users/YourName/Desktop/file.csv
Your CSV data is now imported.
Method 5: Using Python (For Automation)
If you need to import CSV files automatically or regularly, Python is your best option. This is for developers only.
Step 1. Install the MySQL connector
pip install mysql-connector-python
Step 2. Write your import script
import mysql.connector
import csv
connection = mysql.connector.connect(
host="localhost",
user="your_username",
password="your_password",
database="your_database"
)
cursor = connection.cursor()
with open('your_file.csv', 'r') as csv_file:
csv_reader = csv.reader(csv_file)
next(csv_reader)
for row in csv_reader:
sql = "INSERT INTO customers VALUES (%s, %s, %s)"
cursor.execute(sql, row)
connection.commit()
cursor.close()
connection.close()
print("CSV imported successfully!")
Replace your database credentials and table/column names.
Step 3. Run the script
python import_csv.py
Your CSV is imported. Run this script whenever you need to import a new CSV.
Common Problems and How to Fix Them
Column count does not match
Your CSV has 5 columns but your MySQL table has 3. They need to match exactly. Either adjust your table to have all the columns, or delete unnecessary columns from your CSV before importing.
Data type mismatch
Your CSV has text data but your MySQL column is defined as INT for numbers only. Either change the column data type to VARCHAR for text, or clean your CSV data to contain only numbers in that column.
File is too large
phpMyAdmin fails on files over 2MB. Use the command line method or the online converter instead. Both have no size limit.
Special characters look wrong
Your CSV uses a different character encoding than MySQL expects. When importing via command line, add: CHARACTER SET utf8mb4
First row is data, not headers
If your CSV doesn't have a header row but your import tool expects one. Add a header row manually to your CSV first or tell the import tool to not skip the first line.
Dates are in the wrong format
MySQL expects dates as YYYY-MM-DD. If your CSV has dates in other formats like MM/DD/YYYY, either convert them in Excel first or use Python to transform them during import.
When to Use Each Method
Use Method 1 (Online) if you just want it done fast without thinking about it. You don't want to install anything. Your file is under 50MB. You prefer simplicity over technical control.
Use Method 2 (Workbench) if you like visual tools. You're a developer comfortable with desktop apps. You want to see exactly what is happening.
Use Method 3 (phpMyAdmin) if you're on shared hosting. You already have hosting access. Your file is under 2MB. You want the simplest web-based approach.
Use Method 4 (Command Line) if your file is very large (100MB or more). You need maximum speed. You're comfortable with terminal commands. You want zero dependencies.
Use Method 5 (Python) if you import CSV regularly. You want to automate the process. You need to transform data during import. You're a developer with Python experience.
Frequently Asked Questions
Can I import multiple CSV files at once?
Yes. Repeat the import process for each file, or use Python to loop through multiple files and import them automatically.
Does importing a CSV overwrite my existing MySQL data?
No. Importing adds new rows to your table. If you want to replace all data, delete the table contents first with TRUNCATE TABLE customers.
Can I import a CSV into an existing table?
Yes. Just make sure the table has the same column structure as your CSV. The import adds new rows to whatever table you specify.
What if my CSV has the wrong format?
Fix it in Excel or Google Sheets first. Make sure column names match your MySQL table. Data types are correct. There are no extra spaces. Then import.
Is it safe to import CSV files from other people?
Be careful. CSV files can contain anything. Always check the data first before importing into a production database. Import into a test database first.
How long does it take to import a CSV?
A 1MB file imports in seconds. A 100MB file takes a few minutes depending on your server. The command line is always faster than web-based tools.
Conclusion
Importing CSV to MySQL is a common task and it's not complicated once you know which method to use.
For speed and simplicity, the online converter is unbeatable. No setup, no terminal, just upload and convert in seconds.
For larger files or automation, the command line method is fastest.
For developers who want visual control, MySQL Workbench is perfect.
Pick the method that matches your situation and you'll have your CSV data in MySQL in minutes.
👉 Import CSV to MySQL online free: https://dbconverter.site/csv-to-mysql
👉 Need other formats? Convert CSV to Excel, JSON, or SQL: https://dbconverter.site/convert