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

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?

Related

Failed to open file, Error 2 - MySQL Import

I'm trying to import a MySQL Database via command line (Terminal). The file's path seems to be correct, but I keep getting an error message that is most likely showing that, the path of the SQL file I'm importing is not correct. Below is the sample of the command line I'm using and the error I'm getting...
NOTE: Linux Server, Centos 7 - MariaDB
source C:/Users/localcomputerUser/SQLFileFolder/SQLFile.sql
source C:/Users/localcomputerUser/SQLFileFolder/SQLFile.sql
Failed to open file 'C:/Users/localcomputerUser/SQLFileFolder/SQLFile.sql
', error: 2
Thanks for your support.

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

import a csv file into MySQL workbench invalid path

I try to import files using a *.csv file named import personen.csv
when i run this i get an error and the log displays an other path? how can i change this?
LOAD DATA INFILE
'C:\Users\ava\Documents\2_School\1_Informatik\M141\importPersonen.csv' INTO
TABLE persons
FIELDS TERMINATED BY ';' (PiD, Anrede, Name, Vorname, Adresse, Jahrgang, OiD);
this its ther error i get :
Error Code: 29. File 'C:\ProgramData\MySQL\MySQL Server 5.7\Data\UsersavaDocuments2_School1_InformatikM141importPersonen.csv' not found (Errcode: 2 - No such file or directory)
I did already change the my.ini file line to this secure-file-priv="" to import from everywhere
Thanks for the help :D

Error in MySQL to import file.txt

Hello everybody i have some question about MySQL. I want to import text file to inside fields,they come error:
[ERROR 13 (HY000): Can't get stat of '/home/nasimjon/Documents/id_site.txt' (Errcode: 2)
Can someone help me?
Use
LOAD DATA LOCAL INFILE '/home/nasimjon/Documents/id_site.txt' INTO table ...
if you use
LOAD DATA INFILE '/home/nasimjon/Documents/id_site.txt' table ...
If you want to load a file located on the client-side, you have to use the LOCAL keyword :
LOAD DATA LOCAL INFILE'/home/nasimjon/Documents/id_site.txt' ...

Load data infile in mysql not working

i am using the mysql LOAD DATA INFILE, to insert values from csv file to database table.
but here i am using this LOAD DATA INFILE statement in run.sql file, and the t.csv file is also there with run.sql.
When i run the run.sql this line is causing error.if i give the entire path with.csv file name. then it is inserting the values to tables.
how to make it relative path?
LOAD DATA INFILE 't.csv' INTO TABLE movie FIELDS TERMINATED BY ',';
sample from t.csv
,Bulls,dsda
,Bulls,rest
,Bulls,ests
,Bulls,rsts
,Bulls,rets
error message
ERROR 29 (HY000) at line 112: File '/var/lib/mysql/t.csv' not found (Errcode: 2)
A relative filename is interpreted relative to the current working directory when the client program was started, as mentioned in the documentation.
If you did not start the client in /var/lib/mysql the file will not be found.