Using MySQL on Mac OSX. When executing the following statement (from MySQl workbench), I met with the following error,
I tried to start MySQL manually using sudo /usr/local/mysql/support-files/mysql.server start without any options, but still have this error. Wondering if any solutions?
I searched some solutions and looks like on Windows there are some .ini config files, but have not found any solutions on Mac OSX. Thanks.
LOAD DATA INFILE '/Users/foo/Downloads/import.csv'
INTO TABLE tasks
FIELDS TERMINATED BY ','
ENCLOSED BY '"'
LINES TERMINATED BY '\n';
Error Code: 1290. The MySQL server is running with the --secure-file-priv option so it cannot execute this statement 0.0043 sec
Best is to put the file into the server's data directory before trying to load it, for security reasons. Read more about LOAD DATA in the docs, especially about the input file location. Note also: the secure-file-priv option can be set in a config file, hence manually starting the server without any additional option will not change its behavior compared to the normal start.
Related
I'm having to create a local installation of MySQL for development of a Shiny App Dashboard for analytics (R language, my SQL knowledge is basic, for simple bulky queries that I then tune in R).
The deployed version will be on a MS SQL server, therefore I want to setup the basic tables I will use (which are in csv format, small extract of the real thing) to try and optimize my SQL query. I was initially using Postgres SQL but I discovered there are a few syntax differences and therefore I opted to restart and implement MySQL which to my knowledge should be the same with regards to query syntax.
I downloaded the MySQL community Windows installer and installed the
full version to my machine, with all default settings.
I created successfully the server (all default settings) and named it on MySQL Workbench
I then successfully created one test table with all the correct column names etc.
CREATE TABLE servername.test_table( col1 text,
col2 int,
col3 int,
col4 text,
...
col40 text);
Using the below code I tried uploading the CSV to the servername.test_table
LOAD DATA INFILE 'D:\Dropbox\R-Projects\SQL\SAMPLE DATASETS\DATA1.csv'
INTO TABLE servername.test_table
FIELDS TERMINATED BY ','
ENCLOSED BY '"'
LINES TERMINATED BY '\n'
IGNORE 1 ROWS;
The problem arise when I try to upload the csv to the desired table, I am getting:
Error Code: 1290. The MySQL server is running with the --secure-file-priv option so it cannot execute this statement
After some research, instead of meddling with access restrictions which I have no experience with nor fully setting up DBs. The simple possible solution would be to just keep the files in the directory that secure_file_priv would allow.
I ran the SQL command:
SHOW VARIABLES LIKE "secure_file_priv";
Got the directory: C:\ProgramData\MySQL\MySQL Server 8.0\Uploads and saved a copy of the csv file in that directory and then ran the following to try and upload the csv:
LOAD DATA LOCAL INFILE 'C:\ProgramData\MySQL\MySQL Server 8.0\Uploads\DATA1.csv'
INTO TABLE servername.test_table
FIELDS TERMINATED BY ','
ENCLOSED BY '"'
LINES TERMINATED BY '\n'
IGNORE 1 ROWS;
After the above, the following error became the new error:
Error Code: 2068. LOAD DATA LOCAL INFILE file request rejected due to restrictions on access.
Back to research, I began to try and tinker with settings and MySQL command prompt.
Checked what was the server setting for the local_infile with SHOW GLOBAL VARIABLES LIKE 'local_infile'; as a query in MySQL Workbench, result was: Value - ON which to my understanding should have allowed the second attempt using the LOAD DATA LOCAL INFILE to have worked, it did not.
The below link suggested to add the following to the my.ini file.
ERROR 2068 (HY000): LOAD DATA LOCAL INFILE file request rejected due to restrictions on access
[client]
loose-local-infile=1
[mysqld]
local_infile=1
I did as well as restarted the MySQL80 service to see if it implemented... Tried uploading CSV again with no avail.
Could someone please help me upload this CSV so I can focus on my actual work? I've been at this for 2 days and it seems to be a common issue, yet I haven't seen and "dumb-down" step by step troubleshooting like I have presented.
If I may request, please try and provide a step by step approach on how to troubleshoot this. MySQL server mgmt skill are almost null, I'm used to have the access to the DB and simply querying.
Sorry for the long post, but I wanted to be as detailed as possible to show I've tried most of the solutions I've found with no success.
(not sure if this is pertinent: using a Threadripper 3960x workstation with 128GB ram, Windows 10 Pro, MySQL was fully installed in the same drive as Windows 10 Pro is)
Thank you for your time.
Quickest solution was to just deploy on Azure an MS SQL server and utilize the Azure Data Studio Extension called - SQL Server Import. For someone who just wants a server for testing and has to import CSV files that also uses enclosed speech marks. The deployment was quite fast when compared to trying to troubleshoot my local installation.
Im running code in MYSQL works fine no problem.
But when i try to run the same code in R I get the error:
could not run statement: The MySQL server is running with the --secure-file-priv option so it cannot execute this statement
I googled a bit and found alot of people having trouble with running this from their workbench. This isnt my problem though, i can insert from workbench. But I want to do everything from R.
The code im running is:
LOAD DATA
INFILE 'C:\\ProgramData\\MySQL\\MySQL Server 8.0\\Uploads\\Fred_mbf_meta_data.csv'
INTO TABLE fred.fredmetambf
FIELDS TERMINATED BY '\t'
IGNORE 1 LINES
(Title,Series_ID,Frequency,Units,Seas_adj,Start_Date,End_Date,Last_Updated);
I also tried adding >> LOCAL after LOAD DATA LOCAL INFILE.
But then I got the error: "The used command is not allowed with this MySQL version"
Is it game over?
As explained in the documentation, the secure-file-priv option restricts the directory from which files can be imported and exported.
You can use SHOW VARIABLES LIKE "secure_file_priv"; to find out what the current setting is.
Then, you can either move your import file to this directory, or disable the option (this requires modifying the init file and restarting the server).
I keep getting an error 29 that says file is not found with the following syntax and I cannot figure out why:
LOAD DATA INFILE 'C:/Users/rkartj2/Desktop/LOINCSUNQUESTV2.txt'
INTO TABLE xiao
FIELDS TERMINATED BY '\t'
LINES TERMINATED BY '\n'
IGNORE 1 ROWS;
Table xiao has been created in MySQL 5.7 and LOINCSUNQUESTV2.txt was an Excel spreadsheet created on a Windows machine.
While I have not used version 5.7 of Mysql yet, the error you are receiving is the same in previous versions. ERROR 29 (HY000): File 'C:/Users/rkartj2/Desktop/LOINCSUNQUESTV2.txt' not found
This may seem a bit misleading to a newb especially since you can go to your Desktop and see that the LIONSUNQUESTV2.txt file is there.
I see one of two possibilities here which is either that Mysql does not have permissions to access the file from the current directory or that it does not know that the file is on your local server.
You can try using LOAD DATA LOCAL INFILE. From dev.mysql
If that does not work, you need to move file to a location that mysql has access to, such as the Mysql data directory. In version 5.6 of a stock vanilla install it would be in this directory: C:\ProgramData\MySQL\MySQL Server 5.6. Try moving the file there. I believe that Mysql looks at this location by default, so I would change LOAD DATA INFILE 'C:/Users/rkartj2/Desktop/LOINCSUNQUESTV2.txt' to LOAD DATA INFILE 'LOINCSUNQUESTV2.txt'
I'm trying to load data from a CSV using MySQL, but I'm getting Error code 29 (file not found). I'm using mac osx, but when I run the following query
LOAD DATA INFILE '/workspace/SQL_Test/src/values.csv'
INTO TABLE queryid_vs_column
COLUMNS TERMINATED BY ','
MySQL tries to look in 'C:/workspace/SQL_Test/src/values.csv'. I haven't found anyone else with similar issues, has anyone encountered something like this? I'm not sure why MySQL thinks I'm running a windows machine.
Thanks.
If you don't use the LOCAL modifier, it accesses the file on the server. Change your query to:
LOAD DATA LOCAL INFILE '/workspace/SQL_Test/src/values.csv'
INTO TABLE queryid_vs_column
COLUMNS TERMINATED BY ','
I am trying to import a .csv (or .txt it doesn't matter) with MySQL Workbench and I am actually using the following command :
LOAD DATA LOCAL INFILE '/path/to/your/csv/file/model.csv' INTO TABLE test.dummy FIELDS TERMINATED BY ',' ENCLOSED BY '"' LINES TERMINATED BY '\n';
My .csv file is placed in the mysql/data folder of the server where my database is placed (on localhost). MySQL Workbench tells me "Query interrupted".
I previously tried to put the full path but the query was running successfully without results. My database was still empty...
Thanks for your help.
Okay so... Problem solved. It just seems that MySQLWorbench accepts this request with a direct path (no errors, script executed) but doesn't refresh his table view... So my table have been fullfilled around 3 times before I restarted MySQLWorkbench to discover that my table was full.
So... Problem solved. Sorry for the time loss.