I migrated my website to a new server and when importing my database I got an error.
Old server: Mysql 5.5
New SERVER: Mysql 8.0
Here is the import error
[LOAD DATA LOCAL INFILE '/home/xxxx/domaine.com/upload/merchant/13/im_product_ean.sql' INTO TABLE table.PC7_PRODUCT_EAN_ALIAS FIELDS TERMINATED BY '|' ENCLOSED BY ''' LINES TERMINATED BY ' ' (ID, PRODUCT_ID, EAN)] - You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '-table.PC7_PRODUCT_EAN_ALIAS FIELDS TERMINATED BY '|' ENCLOSED BY ''' LINES TE' at line 1 -
The products must import and update in the database with the cronjob
ERROR 1300 (HY000): Invalid utf8mb4 character string: 'ditanlui'
in the file I found two entries (dianli) by column. But when importing, you need to skip the error.
LOAD DATA LOCAL INFILE "0.txt" INTO TABLE table1
FIELDS TERMINATED BY ','
LINES TERMINATED BY '\n';
I import via mysql console
mysql 5.7 version
'mysql> LOAD DATA LOCAL INFILE 'students.csv'
-> INTO TABLE students
-> FIELD TERMINATED BY ',' ENCLOSED BY '"';`
ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'FIELD TERMINATED BY ',' ENCLOSED BY '"'' at line 3.
I'm not sure where my error is occuring. Can someone help me? :(
Can you help me with this request ?
TABLE ben INTO OUTFILE '/tmp/import/output.csv' FIELDS TERMINATED ';' LINES TERMINATED BY '\r\n';
I have this error :
ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'TABLE ben INTO OUTFILE '/tmp/import/output.csv' FIELDS TERMINATED ';' LIN' at line 1
Thank you :)
I think you're missing a 'by`
TABLE ben INTO OUTFILE '/tmp/import/output.csv' FIELDS TERMINATED BY ';' LINES TERMINATED BY '\r\n';
Resource on usage: https://dev.mysql.com/doc/refman/8.0/en/select-into.html
The "TABLE statement" was not added until MySQL 8.0.19. Since you are not running that version, you need to use the slightly more verbose version SELECT ... INTO OUTFILE ... FROM ben ...; (See Gandalf's answer for a link and another syntax error.)
I am trying to use mysql load via the shell prompt. I want to load a CSV file directly into the database.
mysql -u root -p -h mysql -e "LOAD DATA INFILE 'Subscriber.csv' INTO TABLE temp_data FIELDS TERMINATED BY ',' ENCLOSED BY '"' LINES TERMINATED BY '\n'IGNORE 1 ROWS" psi
I am getting the error ERROR 1083 (42000) at line 1: Field separator argument is not what is expected
Below is my CSV file
misdn,city,age,gender
771XXXXXX,MUTOKO,24,MALE
771XXXXXX,MUTOKO,32,MALE
771XXXXXX,MUTOKO,37,Male
771XXXXXX,MUTOKO,36,MALE
771XXXXXX,MUTOKO,25,Male
771XXXXXX,HWEDZA,26,MALE
771XXXXXX,HWEDZA,33,MALE
771XXXXXX,MUTOKO,26,MALE
771XXXXXX,HWEDZA,34,MALE
771XXXXXX,HWEDZA,34,MALE
771XXXXXX,MUTOKO,21,MALE
771XXXXXX,MUTOKO,22,MALE
771XXXXXX,MUTOKO,30,MALE
771XXXXXX,MUTOKO,28,Male
771XXXXXX,MUTOKO,33,Male
771XXXXXX,MUTOKO,23,Male
771XXXXXX,ZVISHAVANE,31,Male
771XXXXXX,ZVISHAVANE,39,MALE
Please help, what I am doing wrong?
You used ENCLOSED BY '"', but your fields do not contain double quotes at all. I think you should have used OPTIONALLY ENCLOSED BY '"'. Try this version:
mysql -u root -p -h mysql -e "LOAD DATA INFILE 'Subscriber.csv'
INTO TABLE temp_data
FIELDS TERMINATED BY ','
OPTIONALLY ENCLOSED BY '"'
LINES TERMINATED BY '\n'IGNORE 1 ROWS" psi
Or, if you are certain that no fields will ever have double quotes, you could remove the ENCLOSED BY clause entirely.