mysql error (HY000):file not found (Errcode: 2) - mysql

So I'm trying to load my database by loading .txt file (fields terminated by \t). But it keeps sending me this error:
mysql> LOAD DATA LOCAL INFILE "C:\\tvshow.txt" INTO TABLE SERIJA FIELDS TERMINATED BY '\t' LINES TERMINATED BY '\n';
ERROR 2 (HY000): File 'C:\tvshow.txt' not found (Errcode: 2)
Can somebody help me out?
(I'm using PuTTY on Windows 10)

Related

why it is not imported. how to skip errors?

ERROR 1300 (HY000): Invalid utf8mb4 character string: 'ditanlui'
in the file I found two entries (dianli) by column. But when importing, you need to skip the error.
LOAD DATA LOCAL INFILE "0.txt" INTO TABLE table1
FIELDS TERMINATED BY ','
LINES TERMINATED BY '\n';
I import via mysql console
mysql 5.7 version

ERROR 13 (HY000): Can't get stat of '/tmp/file1.csv' (Errcode: 2) while trying to import CSV file into MariaDB

I am trying to import CSV file into MariaDB (version: 5.5.50-MariaDB MariaDB Server), using this command:
LOAD DATA INFILE 'file1.csv'
INTO TABLE table_name
FIELDS TERMINATED BY ','
LINES TERMINATED BY '\n'
IGNORE 1 LINES (#dummy,col1, col2,col3,#dummy)
SET col4 = "xyz";
I am getting error as:
ERROR 13 (HY000): Can't get stat of '/var/lib/mysql/db_name/file1.csv' (Errcode: 2)
I also tried using LOCAL keyword as per some suggestions on stackoverflow and google search in the above query like:
LOAD DATA LOCAL INFILE 'file1.csv'
INTO TABLE table_name
FIELDS TERMINATED BY ','
LINES TERMINATED BY '\n'
IGNORE 1 LINES (#dummy,col1, col2,col3,#dummy)
SET col4 = "xyz";
in that case, I get a file not found error:
ERROR 2 (HY000): File 'file1.csv' not found (Errcode: 2)
I have tried moving my source file to /tmp, /root and /var/lib/mysql/db_name directories but am not able to import using any of the above queries.
Could anyone please suggest a solution?
Thanks in advance.
The file needs to be either owned by "mysql", or readable by by "mysql". Do ls -l file1.csv if you need further interpretation.
Also, check the value of local_infile.

Unable to load the data from file to Mysql table

I am unable to load the data from file to a MySQL table.
Where else should I keep the file?
File is present as shown below.
notroot#ubuntu:~/lab/data$ ls
txns
notroot#ubuntu:~/lab/data$ pwd
/home/notroot/lab/data
notroot#ubuntu:~/lab/data$ mysql -u root -p
mysql> load data infile '/home/notroot/lab/data/txns' into table trans fields terminated by ',' lines terminated by '\n';
ERROR 29 (HY000): File '/home/notroot/lab/data/txns' not found (Errcode: 13)
mysql> load data local infile '/home/notroot/lab/data/txns' into table trans fields terminated by ',' lines terminated by '\n';
ERROR 1148 (42000): The used command is not allowed with this MySQL version
mysql>
Use the --local-infile parameter when running mysql
mysql --local-infile -u root -p

Exporting sql data from mysql server into csv file in local mac computer Help,

when I attempt to take the data I have from my mysql server and generate a csv file with this command:
select * from table into outfile '/Users/username/Desktop/testfile.csv' fields terminated by ',' enclosed by '"' lines terminated by '/n';
I end up with the error:
ERROR 1 (HY000): Can't create/write to file '/Users/username/Desktop/testfile.csv' (Errcode: 13 - Permission denied)
Another weird problem is I can't seem to stop the server from running through the preference pane, maybe they are related. Anyways, thanks for the help!
Try this:
SELECT * FROM table INTO OUTFILE '/tmp/myfile.csv' FIELDS TERMINATED BY ',' OPTIONALLY ENCLOSED BY '"';
Then in you terminal, cd to the tmp directory, do ls to see if the file is there and when you are in that tmp directory, just do open myfile.csv

Error when trying to export table to a csv file (errcode: 2)

I'm trying to export my table to a .csv file. The query (mysql) is:
SELECT *
FROM TEMP_FINAL
INTO OUTFILE '/home/test/TEMP_FINAL.csv'
FIELDS TERMINATED BY ';'
LINES TERMINATED BY '\n';
I get the following error:
"Can't create/write to file '/home/test/TEMP_FINAL.csv' (Errcode: 2)
The directory "test" has permission to write and I`m using Ubuntu 12.04.5 LTS.
What is wrong and how to fix it?
The mysql program does not have access to a user's directory. Change the outfile to somewhere like /tmp/ and move the file later.