I have an Excel file (.xlsx format) and I want to import it to my database.
I first saved it in .csv format and I checked spelling because I have some fields with text that is formatted for Romanian language with diacritics and it’s OK.
Then I made the table with the column names and imported the table using phpMyAdmin selecting
Character set of the file: utf-8 and the format using
Format: CSV using LOAD DATA.
It loads fine except I lose all Romanian diacritics and I have a column with text that doesn’t import all text, it stops if he finds a Romanian letter ex: (ă,â,î,ș,ț).
What formatting should i use? for Romanian language is recommended utf-8.
Edit 1: OK, Wilk helped me with the solution and i think it’s this:
SET NAMES utf8; LOAD DATA INFILE '/home/public_html/db/test_db.csv' INTO TABLE test_db FIELDS TERMINATED BY ';' ENCLOSED BY '"' ESCAPED BY '\' LINES TERMINATED BY '\r\n';
But now i have a new error
#1045 – Access denied for user ‘user’@’localhost’ (using password: YES). 🙂
SET NAMES utf8
Put it in line before
Your full SQL should look like:
SET NAMES utf8 LOAD DATA INFILE 'file.csv' INTO TABLE your_table FIELDS TERMINATED BY ',' LINES TERMINATED BY '\n'
FIELDS TERMINATED BY operator is your field seperator