3

When I start the MySQL bash client, I have been starting it with --local-infile=1 so that I can import data from a .csv file.

Is there any way of doing this within MySQL Workbench?

2 Answers 2

1

According to the MySQL Documentation on LOAD DATA INFILE

For security reasons, when reading text files located on the server, the files must either reside in the database directory or be readable by all. Also, to use LOAD DATA INFILE on server files, you must have the FILE privilege. See Section 6.2.1, “Privileges Provided by MySQL”. For non-LOCAL load operations, if the secure_file_priv system variable is set to a nonempty directory name, the file to be loaded must be located in that directory.

As long as you have FILE privilege, you can do this in SQL Editor

SET GLOBAL local_infile = 1;
0
SET GLOBAL local_infile = 1;    works fine 

and then your statement:

LOAD DATA LOCAL INFILE '/Users/XYZ/Desktop/mysqlData.txt'
INTO TABLE SQLprep.orders FIELDS TERMINATED BY ','
ENCLOSED BY '"' LINES TERMINATED BY '\n';

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.