Question

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?

Was it helpful?

Solution

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;

OTHER TIPS

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';
Licensed under: CC-BY-SA with attribution
Not affiliated with dba.stackexchange
scroll top