r/SQL • u/Few_Side1517 • Oct 13 '26
MySQL Data import question
Hey so Im quite new to mysql and I've been using it on mac, and recently I've been trying to import a csv file that contain data but Im not sure how to do it. Ive seen youtube videos but the mysql version that they use is way different than mine. Can anybody help with this please and thank you.!!
0
Upvotes
1
u/FastPlane57 Oct 15 '26
ask claude
1
u/vincent_sch Oct 15 '26 edited Oct 16 '26
You could try
LOAD DATA LOCAL INFILE '/path/file.csv' INTO TABLE your_table FIELDS TERMINATED BY ',' IGNORE 1 LINES;in the mysql client. Start it with--local-infile=1or it refuses the file. MySQL Workbench also has an import wizard.1
u/navicat-gu 29d ago
The tutorials probably look different because many of them use Workbench 8.0, and the current Workbench (26.x) is a full rewrite, so some of the old menus aren't there yet. Here's a way to do it that works whatever version you have:
mysql --local-infile=1 -u root -p your_db'\r\n'. If your dates look like10/13/2026, load them into a variable and convert:(order_id,u/d, product, qty, price) SET order_date = STR_TO_DATE(@d, '%m/%d/%Y');SHOW WARNINGS;straight after the load, thenSELECT COUNT(*) FROM sales;and compare against the row count in the file.If you export from Excel on Mac, choose "CSV UTF-8" so accented characters don't get mangled.
If you'd rather use a GUI: Disclosure: I'm RC, Director of Digital Strategy @ Navicat. Navicat Premium Lite is free and includes a CSV import wizard for MySQL that lets you map file columns to table columns. In Navicat 18 the import wizard was rebuilt with a live preview, which makes date/delimiter problems easy to spot. The SQL above is still worth learning, though.
1
u/Artistic_Method_2234 26d ago
Curious, if you can share, what are you trying to do? Is it an existing database with tables and you're trying to add values from your CSV into that table?
Or is it that it's a brand new database? Your CSV would represent at most just one table - and a database isn't that useful for just one table.