Importing CSV data into a MySQL/MariaDB database is a common task for populating product catalogs, contact lists, or migrating data from spreadsheets. Here are the best methods on your hosting account.
Import CSV via phpMyAdmin
Open phpMyAdmin, select the target table, click "Import," choose your CSV file, set the format to "CSV," configure column separators and enclosures, and click "Go." phpMyAdmin handles the parsing automatically.
01. Import via phpMyAdmin
- Create the target table first with columns matching your CSV structure (or use an existing table)
- Select the table in phpMyAdmin
- Click "Import"
- Choose your CSV file
- Format: CSV
- Set the column separator (usually comma), text qualifier (usually double quote), and whether the first row contains column names
- Click "Go"
02. Import via SQL
Upload your CSV to your hosting account, then run this SQL in phpMyAdmin:
LOAD DATA LOCAL INFILE '/home/username/data.csv'
INTO TABLE tablename
FIELDS TERMINATED BY ','
ENCLOSED BY '"'
LINES TERMINATED BY '\n'
IGNORE 1 ROWS;
The IGNORE 1 ROWS skips the header row if your CSV has column names.
If LOAD DATA LOCAL INFILE is disabled on the server (common on shared hosting for security), use the phpMyAdmin import method instead, or write a PHP script that reads the CSV with fgetcsv() and inserts rows via prepared statements.
For exporting data, see MySQL Import/Export Format. For phpMyAdmin usage, see View/Modify Data in MySQL.
Data Import Help?
Open a Support TicketQuick Recap
- phpMyAdmin Import is the easiest method
- Create the table first with matching columns
- Set CSV format options (separator, qualifier, header row)
- LOAD DATA INFILE for SQL-based import (may be restricted)
- Use fgetcsv() in PHP as an alternative
Database operations · Last updated March 2026 · Browse all PHP/MySQL articles
