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.)
Related
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
I am trying to export query results from MySQL to CSV using SQL by the following query.
SELECT *
FROM Book
INTO OUTFILE '/Users/<MY_NAME>/Desktop/folder1/folder2/book.csv'
FIELDS TERMINATED BY ',' OPTIONALLY ENCLOSED BY '"'
LINES TERMINATED BY '\n';
After executing above SQL query I am getting a following error.
Error Code: 1290. The MySQL server is running with the --secure-file-priv option so it cannot execute this statement
I tried by editing .my.cnf file to secure_file_priv='', But still I am getting same error.
I ran the SHOW VARIABLES LIKE 'secure_file_priv'; query. But, I am getting:
# Variable_name, Value
'secure_file_priv', 'NULL'
could someone tell me what am i doing wrong?
that's what I type in MySQL shell
-> LOAD DATA INFILE C:\ProgramData\MySQL\MySQL Server 8.0\Uploads\aavoc.csv
-> INTO TABLE googlecoursera.table1
-> FIELDS TERMINATED BY ','
-> ENCLOSED BY '"'
-> LINES TERMINATED BY '\r\n'
-> IGNORE 1 LINES;
and that's what I get
ERROR: Unknown command '\P' ERROR: Unknown command '\M' ERROR:
Unknown command '\M' ERROR: Unknown command '\U' ERROR:
Unknown command '\a' 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 'C:rogramDataySQLySQL
Server 8.0ploadsavoc.csv LOAD DATA INFILE C:rogramDataySQLy' at
line 1
It might be / instead of \ for ':\ProgramData\MySQL\MySQL Server 8.0\Uploads\aavoc.csv'. Try using '/'
Put quotes around the file name.
LOAD DATA INFILE 'C:\ProgramData\MySQL\MySQL Server 8.0\Uploads\aavoc.csv'
INTO TABLE googlecoursera.table1
FIELDS TERMINATED BY ','
ENCLOSED BY '"'
LINES TERMINATED BY '\r\n'
IGNORE 1 LINES;
I have a local file structured as follows;
E312D72A2D671437F87446170460320B7F0B53CE:1
E31A0888C42FDE105EA887F2EC8DF1ABF5DBFAA0:1
E326561AE42192053CC09D5EA15DE54230AE4510:1
I want to load this file into a table. The table has 3 columns col1,col2, and col3. I'm using the syntax from dev-mysql as;
LOAD DATA LOCAL INFILE 'input.txt'
INTO table myTable(col1,col2) FIELDS TERMINATED BY ':';
It gives an error as
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 'FIELDS TERMINATED BY ':'' at line 1
What is the reason for this error? What is the correct syntax?
And, yes my file has two fields and I want to insert them into a table with 3 columns, the last column can be NULL.
mysql --version
mysql Ver 8.0.23-0ubuntu0.20.04.1 for Linux on x86_64 ((Ubuntu))
You should write it this way:
LOAD DATA LOCAL INFILE 'input.txt'
INTO table myTable FIELDS TERMINATED BY ':' (col1,col2);
'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? :(