LOAD DATA FROM CSV FILE - mysql

I am using MacOS for Catalina MySQL.
When I enter the following in Terminal
mysql> LOAD DATA INFILE ‘/Users/MyData/MDRC/Bible Modules/Crosswire_kjv_002.csv’ INTO TABLE tbl_texts_kjv_from_csv FIELDS TERMINATED BY ',';
the response is:
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 '‘/Users/MyData/MDRC/Bible Modules/Crosswire_kjv_002.csv’ INTO TABLE tbl_text' at line 1
But my input seems to match the refman-8.0-en.pdf. It also seems to match the recomendation in 'Learning MySQL' from O'reilly. I have tried various variations of input, all with the same response.
The file mysql-errors-8.0-en.a4.pdf says:
Error number: 1064; Symbol: ER_PARSE_ERROR; SQLSTATE: 42000
Message: %s near '%s' at line %d
which tells me nothing more than the response.

You need single quote around the file name
LOAD DATA INFILE '/Users/MyData/MDRC/Bible Modules/Crosswire_kjv_002.csv' INTO TABLE tbl_texts_kjv_from_csv FIELDS TERMINATED BY ',';

Related

How can I resolve 1290 error code in MYSQL 8.0

I've searched and found several proposed solutions to this however, none work.
I'm attempting to run the commands below:
LOAD DATA INFILE 'd:\ProgramData\MySQL\MySQL Server 8.0\Uploads\pa_ballot_request'
INTO TABLE pa_ballot_request
FIELDS TERMINATED BY ',' ENCLOSED BY ''
LINES TERMINATED BY '\r\n'
IGNORE 1 ROWS
I'm getting the 1290 error: MySQL server is running with the –secure-file-priv”
The secure-file-priv line is pointing to the directory where my *.csv is located yet I still get the error.
I've tried commenting out the secure-file-priv line in my.ini and I continue to get the error.
I've turned off the Safe Updates option in MySQL Workbench.
I'm running MySQL 8.0.21
Instead of commenting it, change the value of the variable into null.
In the notepad where you find secure-file-priv line, write the following line:
secure-file-priv=""
This solves the problem in MySQL 8.0
After solving this, you may get Error 29 while execution, which is incorrect file path. This can be solved by using \\ in place of \ in the path line.
I have attempted changing all of the \ to / as well as \\ which I had seen other mentioning has worked for them on older versions of MySQL. This modification did not work for me.

Load input table not honoring secure_file_priv

I ran SHOW VARIABLES LIKE "secure_file_priv" and I got this result:
'secure_file_priv', 'C:\ProgramData\MySQL\MySQL Server 8.0\Uploads\'
I loaded the csv file to the Uploads directory and ran this command:
load data infile 'C:\ProgramData\MySQL\MySQL Server 8.0\Household.csv' replace into table bb.household
fields ENCLOSED BY '"'
ESCAPED BY '\\'
;
I got the following :
Error Code: 1290. The MySQL server is running with the --secure-file-priv option so it cannot execute this statement.
What am I missing? I even tried "C:\ProgramData\MySQL\MySQL Server 8.0\Household.csv" as the file path and I still got the error code above.
What am I missing? Any suggestions would be greatly appreciated.
MG

MySQL Error 29. SQL not using correct file path

Working on using the LOAD DATE INFILE syntax to import my csv files into my database. Using windows 10.
Originally when using this syntax I was getting ERROR 1290 which I resolved by adding: secure-file-priv = "" to the .ini file.
I no longer get ERROR 1290 but when i use:
LOAD DATA INFILE 'C:\Users\ovoJa\Downloads\VEN01_562.csv'
INTO TABLE venom
FIELDS TERMINATED BY ','
ENCLOSED BY '"'
LINES TERMINATED BY '\n'
I get this ERROR 29:
File 'C:\ProgramData\MySQL\MySQL Server 8.0\Data\UsersovoJaDownloadsVEN01_562.csv' not found (OS errno 2 - No such file or directory)
Why is it still looking in the Programdata file for the .csv file?
try to use this C:\\Users\\ovoJa\\Downloads\\VEN01_562.csv

Can't load a file to mysql table: Errcode: 2 - No such file or directory

I want to load file into a table. I am using this command.
LOAD DATA LOCAL INFILE 'home/myuser/Documents/my_project/project_sub_directory/project_sub_directory2/project_sub_directory3/my_data_file.txt'
INTO TABLE `mydatabse`.`my_table`
fields terminated BY ',';
I use LOCAL in the command to avoid the following error (an avoid moving my data files to another directory):
Error Code: 1290. The MySQL server is running with the
--secure-file-priv option so it cannot execute this statement
After executing the command, I get this error:
Error Code: 2. File
'home/myuser/Documents/my_project/project_sub_directory/project_sub_directory2/project_sub_directory3/my_data_file.txt'
not found (Errcode: 2 - No such file or directory)
How to resolve the issue without moving my data file to another directory?

MySQL no longer shows error message, only code

Since I upgraded to MYSQL 5.7.16, I no longer have error messages, which is annoying (I now have to remember all codes) and gets very very annoying when it comes to SQL 1064 (Error: 1064 SQLSTATE: 42000 (ER_PARSE_ERROR) %s near '%s' at line %d says the doc... so easy to debug with no info nor line number).
Same goes for warnings: if a line returns a warning, I can no longer read it (show warnings doesn't crash, but it returns no result).
So I bet (hope!) MySQL made a configuration change: what's the option to get the MySQL error messages back?
The problem is related to the lc-messages-dir directive.
In last versions, the default dir is wrong (at least under Debian).
Put this into your mysql.cnf :
lc-messages-dir = /usr/share/mysql/english/
And error messages will be back ;)